A program to determine the range of values and the average cost of a personal computer (P.C.) in the market.


#include
main()
{ int count=0;
float value, high, low, sum=0, average, range;
clrscr();
printf("Enter numbers in a line: input a NEGAATIVE number to end\n");

input:
scanf("%f",&value);
if(value<0)
goto output;
count+=1;
if(count==1)
high=low=value;
else if(value>high)
high=value;
else if(value
low=value;
sum+=value;
goto input;

output:

average=sum/count;
range=high-low;
printf(“\n\n”);
printf(“Total values: %d\n”, count);
printf("Highest-value: %f\n Lowest-value: %f\n”, high, low);
printf(“Range : %f\nAverage : %f\n”, range, average);
getch();
}

No comments:

Post a Comment