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



design and implement a program that reads floating-points numbers in a sentinel-controlled loop un..

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

design and implement a program that reads floating-points numbers in a sentinel-controlled loop un..

Answer / 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

More C Interview Questions

what is a c-language.what is do.

4 Answers   HCL,


What is variable and explain rules to declare variable in c?

0 Answers  


What is a pointer in c plus plus?

0 Answers  


What is the function of this pointer?

0 Answers   Agilent, ZS Associates,


sir i got 146 correct question & i have also the advantage of height so will they consider my marks as 146+3=149.can any body tell me how they consider my height marks.

1 Answers  






`write a program to display the recomended action depends on a color of trafic light using nested if statments

0 Answers  


#include<stdio.h> { printf("Hello"); } how compile time affects when we add additional header file <conio.h>.

0 Answers  


Write a program that can show the multiplication table.

0 Answers   Student,


What is omp_num_threads?

0 Answers  


What is && in c programming?

0 Answers  


difference between Low, Middle, High Level languages in c ?

0 Answers   Bosch, Infosys,


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

0 Answers  


Categories