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
Explain what is the difference between a free-standing and a hosted environment?
How can you increase the size of a dynamically allocated array?
Is c pass by value or reference?
how could explain about job profile
Do pointers take up memory?
What is structure padding in c?
How are 16- and 32-bit numbers stored?
Does c have function or method?
What is integer constants?
When can you use a pointer with a function?
int i=10; printf("%d %d %d", i, i=20, i);
What is malloc calloc and realloc in c?
In a header file whether functions are declared or defined?
Can an array be an Ivalue?
How can you return multiple values from a function?