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

Explain what is the difference between a free-standing and a hosted environment?

637


How can you increase the size of a dynamically allocated array?

650


Is c pass by value or reference?

601


how could explain about job profile

1460


Do pointers take up memory?

666






What is structure padding in c?

632


How are 16- and 32-bit numbers stored?

728


Does c have function or method?

596


What is integer constants?

626


When can you use a pointer with a function?

574


int i=10; printf("%d %d %d", i, i=20, i);

1018


What is malloc calloc and realloc in c?

674


In a header file whether functions are declared or defined?

633


Can an array be an Ivalue?

668


How can you return multiple values from a function?

638