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
What is stack in c?
If fflush wont work, what can I use to flush input?
What does 3 periods mean in texting?
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
Can we change the value of static variable in c?
What are the different types of control structures?
What is a spanning Tree?
When should you use a type cast?
What are lookup tables in c?
What is restrict keyword in c?
What does c mean before a date?
Write a program to print fibonacci series without using recursion?
How do you define a string?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
What is the benefit of using #define to declare a constant?