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.
Answers were Sorted based on User's Feedback
Answer / 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 |
#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 |
What is variable in c example?
Can you explain the four storage classes in C?
the data type used for unlimited value in c and how to do this program
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
what is foreign key in c language?
What is the difference between class and object in c?
write a function to find whether a string is palindrome or not and how many palindrome this string contain?
plz answer..... a program that reads non-negative integer and computes and prints its factorial
What is function and its example?
Tell me what is null pointer in c?
Is a house a shell structure?
p*=(++q)++*--p when p=q=1 while(q<=6)