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 purpose of macro in C language?
what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;
What is printf () in c?
Can you tell me how to check whether a linked list is circular?
I need previous papers of CSC.......plz help out by posting them.......
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
Write a program to check prime number in c programming?
What is structure in c language?
write a proram to reverse the string using switch case?
What is far pointer in c?
What are high level languages like C and FORTRAN also known as?
difference between object file and executable file
Explain union. What are its advantages?
Can we initialize extern variable in c?
Write a factorial program using C.