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 / yogesh

#include<stdio.h>
#define MAX 20
int main()
{
float no,a[MAX],sum=0.0,avg;
int n,i;
float min,max;
printf("\n Enter How Many Numbers:");
scanf("%d",&n);
i=0;
min=0;
max=0;
do
{
printf("\n Enter a number(Enter 0 to
stop):");
scanf("%f",&no);
a[i]=no;
if(no==0)
break;
else
{
if(a[i]<min)
min=a[i];
else if(a[i]>max)
max=a[i];
sum=sum+a[i];
}
i++;
}
while(i<n);
avg=sum/i;
printf("\n The Smallest Number is:%f",min);
printf("\n The Largest Number is:%f",max);
printf("\n The Average of Entered %d numbers is:%.2f
\n",i,avg);
}

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a variable be both constant and volatile?

815


Explain what are linked list?

804


What is strcmp in c?

749


How many types of operator or there in c?

841


What is the best way to comment out a section of code that contains comments?

1072


What is the purpose of main( ) in c language?

879


What is bubble sort technique in c?

766


what is the diffrenet bettwen HTTP and internet protocol

1591


Explain how can I manipulate strings of multibyte characters?

984


How many keywords are there in c?

807


What is hashing in c language?

841


Explain how can you be sure that a program follows the ansi c standard?

1138


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2529


What are file streams?

772


Explain b+ tree?

826