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


Please Help Members By Posting Answers For Below Questions

What are compound statements?

631


in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures

680


how logic is used

1504


What is C language ?

1533


Which function in C can be used to append a string to another string?

649






What is context in c?

543


What is the use of typedef in c?

593


What is function what are the types of function?

563


What is #define size in c?

652


In c language can we compile a program without main() function?

584


Explain what are bus errors, memory faults, and core dumps?

794


How can I pad a string to a known length?

614


What's a good way to check for "close enough" floating-point equality?

630


What is main return c?

523


Why should I use standard library functions instead of writing my own?

676