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


Please Help Members By Posting Answers For Below Questions

Why do we use static in c?

629


What is the use of ?: Operator?

660


Tell me what is null pointer in c?

610


Without Computer networks, Computers will be half the use. Comment.

1866


Is r written in c?

722






Differentiate between static and dynamic modeling.

613


What does s c mean in text?

605


What is operator promotion?

623


In c programming language, how many parameters can be passed to a function ?

626


Do you know the difference between malloc() and calloc() function?

606


List some basic data types in c?

557


What is string in c language?

617


What does printf does?

738


What is hungarian notation? Is it worthwhile?

690


What is the hardest programming language?

661