57. Write a program that reads a list of integers from the keyboard and creates
ID: 3619557 • Letter: 5
Question
57. Write a program that reads a list of integers from the keyboard and creates the following information: a. Finds and prints the sum and the average of the integers. b. Finds and prints the largest and the smallest integer c. Prints a Boolean (true or false) if some of them are less than 20 d. Prints a Boolean (true or false) if all of them are between 10 and 90 The input data consist of a list of integers with a sentinel. The program must prompt the user to enter the integers, one by one, and enter the sentinel when the end of the list has been reached. The prompt should look like the following: Enter numbers with (99999 to stop): The output should be formatted as shown below. The number of integers is: xxx The sum of the integers is: xxxx The average of the integers is: xxx.xx The smallest integer is: xxx The largest integer is: xxx At least one number was All numbers were (10 = 90):Explanation / Answer
please rate - thanks #include<stdio.h>#include<conio.h>
int main()
{int n,sum=0,large,small,count=0;
double average;
int less20=0,between10and90=1;
printf("Enter numbers with (99999 to stop):");
scanf("%d",&n);
large=n;
small=n;
while(n!=99999)
{sum+=n;
if(n>large)
large=n;
else
if(n
n=small;
if(n<20)
less20=1;
if(n<10||n>90)
between10and90=0;
count++;
printf("Enter numbers with (99999 to stop):");
scanf("%d",&n);
}
printf("The number of integers is: %3d ",count);
printf("The sum of the integers is: %3d ",sum);
average=(double)sum/count;
printf("The average of the integers is: %5.2f ",average);
printf("The smallest integer is: %3d ",small);
printf("The largest integer is: %3d ",large);
if(less20)
printf("At least 1 number was less than 20 ");
else
printf("All the numbers were at least 20 ");
if(!between10and90)
printf("At least 1 number was not between 10 and 90 ");
else
printf("All the numbers were between 10 and 90 ");
getch();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.