design and implement a program that reads floating-points
numbers in a sentinel-controlled loop until the user
terminates the program by entering zero.your program should
determinate and print the smallest,largest and average of
the supplied numbers.
Answer Posted / yogesh
#include<stdio.h>
#define MAX 20
int main()
{
float no,a[MAX],sum=0.0,avg;
int n,i;
float min,max;
printf("\n Enter How Many Numbers:");
scanf("%d",&n);
i=0;
min=0;
max=0;
do
{
printf("\n Enter a number(Enter 0 to
stop):");
scanf("%f",&no);
a[i]=no;
if(no==0)
break;
else
{
if(a[i]<min)
min=a[i];
else if(a[i]>max)
max=a[i];
sum=sum+a[i];
}
i++;
}
while(i<n);
avg=sum/i;
printf("\n The Smallest Number is:%f",min);
printf("\n The Largest Number is:%f",max);
printf("\n The Average of Entered %d numbers is:%.2f
\n",i,avg);
}
Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
Can a variable be both constant and volatile?
Explain what are linked list?
What is strcmp in c?
How many types of operator or there in c?
What is the best way to comment out a section of code that contains comments?
What is the purpose of main( ) in c language?
What is bubble sort technique in c?
what is the diffrenet bettwen HTTP and internet protocol
Explain how can I manipulate strings of multibyte characters?
How many keywords are there in c?
What is hashing in c language?
Explain how can you be sure that a program follows the ansi c standard?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
What are file streams?
Explain b+ tree?