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 difference between declaring a variable by constant keyword and #define ing that variable?
What are near, far and huge pointers?
What is maximum size of array in c?
What does the function toupper() do?
will u please send me the placement papers to my mail???????????????????
How can you draw circles in C?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
Write the control statements in C language
What do the functions atoi(), itoa() and gcvt() do?
What is the use of a semicolon (;) at the end of every program statement?
Why c language?
how to introdu5ce my self in serco
Is it better to bitshift a value than to multiply by 2?
Why is sizeof () an operator and not a function?