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
Is that possible to store 32768 in an int data type variable?
Do variables need to be initialized?
What are static variables in c?
Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)
A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles
What happens if you free a pointer twice?
How do you do dynamic memory allocation in C applications?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
Why is c faster?
Can you write a programmer for FACTORIAL using recursion?
What is the right type to use for boolean values in c? Is there a standard type?
Why & is used in c?
Write a program with dynamically allocation of variable.
What is wrong with this program statement? void = 10;
Why is it important to memset a variable, immediately after allocating memory to it ?