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

What is stack in c?

609


If fflush wont work, what can I use to flush input?

611


What does 3 periods mean in texting?

595


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

1645


Can we change the value of static variable in c?

556






What are the different types of control structures?

580


What is a spanning Tree?

950


When should you use a type cast?

587


What are lookup tables in c?

548


What is restrict keyword in c?

638


What does c mean before a date?

585


Write a program to print fibonacci series without using recursion?

602


How do you define a string?

649


How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

647


What is the benefit of using #define to declare a constant?

601