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 / 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 |
Post New Answer View All Answers
Write an algorithm for implementing insertion and deletion operations in a singly linked list using arrays ?
Is it acceptable to declare/define a variable in a c header?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
What is the maximum no. of arguments that can be given in a command line in C.?
What is c variable?
What is const and volatile in c?
Does * p ++ increment p or what it points to?
What is use of #include in c?
What does main () mean in c?
What is the difference between strcpy() and memcpy() function in c programming?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
What is zero based addressing?
What is meant by int main ()?
What is the auto keyword good for?
How does free() know explain how much memory to release?