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 we use stdio h in c?
What is the difference between union and anonymous union?
How can I write a function that takes a format string and a variable number of arguments?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
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.
What is static memory allocation? Explain
What are header files and explain what are its uses in c programming?
Who developed c language?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What are structure members?
How can I change their mode to binary?
Does c have an equivalent to pascals with statement?
Why does the call char scanf work?
What is meant by high-order and low-order bytes?
What are type modifiers in c?