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
What is the use of void pointer and null pointer in c language?
What is use of bit field?
Why we use conio h in c?
Which header file is used for clrscr?
Difference between linking and loading?
What is void c?
What functions are used in dynamic memory allocation in c?
What happens if you free a pointer twice?
When should you not use a type cast?
What are types of structure?
Explain b+ tree?
What does p mean in physics?
Why structure is used in c?
Why flag is used in c?
What does dm mean sexually?