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
What is the use of typedef in c?
What is non linear data structure in c?
What does the format %10.2 mean when included in a printf statement?
Explain the Difference between the New and Malloc keyword.
Where can I get an ansi-compatible lint?
What is pointer to pointer in c language?
What is structure padding and packing in c?
In c language can we compile a program without main() function?
Explain how can I convert a string to a number?
What are pointers in C? Give an example where to illustrate their significance.
What is the size of a union variable?
What is the correct code to have following output in c using nested for loop?
can any one provide me the notes of data structure for ignou cs-62 paper
What is variables in c?
which is an algorithm for sorting in a growing Lexicographic order