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 / sagarraje nimbalkar
// above student asking user How many no. ? but their is no
need to ask because when user want to stop he will enter o(zero)
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
float max=0, min=0;
do
{
float n, sum=0, avg=0;
printf("Enter the %d th number: ",i);
scanf("%f",&n);
if(n==0)
exit(0);
else
{
sum=float(sum+n);
if(n>max)
max=n;
else
min=n;
}
i++;
while(1);
printf(" The maximum no. is %f and minimum no. is %f and
average of all no is %f",max,min,sum/i);
getch();
}
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Why do we use static in c?
What is the use of ?: Operator?
Tell me what is null pointer in c?
Without Computer networks, Computers will be half the use. Comment.
Is r written in c?
Differentiate between static and dynamic modeling.
What does s c mean in text?
What is operator promotion?
In c programming language, how many parameters can be passed to a function ?
Do you know the difference between malloc() and calloc() function?
List some basic data types in c?
What is string in c language?
What does printf does?
What is hungarian notation? Is it worthwhile?
What is the hardest programming language?