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 we use stdio h in c?

598


What is the difference between union and anonymous union?

843


How can I write a function that takes a format string and a variable number of arguments?

613


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

1687


When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.

1544






What is static memory allocation? Explain

640


What are header files and explain what are its uses in c programming?

623


Who developed c language?

646


what do u mean by Direct access files? then can u explain about Direct Access Files?

1653


What are structure members?

605


How can I change their mode to binary?

710


Does c have an equivalent to pascals with statement?

580


Why does the call char scanf work?

626


What is meant by high-order and low-order bytes?

663


What are type modifiers in c?

632