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 string in c language?
Explain the difference between exit() and _exit() function?
Why ca not I do something like this?
What is meant by recursion?
Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me
What are pragmas and what are they good for?
How does selection sort work in c?
Sir i need notes for structure,functions,pointers in c language can you help me please
Is c still used?
What is pass by reference in c?
How does placing some code lines between the comment symbol help in debugging the code?
What is time complexity c?
Why pointers are used?
Why c language is called c?
Explain continue keyword in c