Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will loop ten times. In each iteration prompt user to enter

ID: 3596421 • Letter: W

Question

Write a program that will loop ten times. In each iteration prompt user to enter an integer between -50&50. Print the input, keep a running sum of the inputs, and track the minimun and maximum numbers input. After the loop is complete, minimum number entered, maximum number entered, sum of all numberes entered, and average of all numbers entered.

Format all output. Before running the loop, print the label "Input values: ". Within the loop, print value entered by user followed by a comma and a space (", ") unless it is the last input. In that case print a newline instead.

Print remaining values on their own line providing a formatted label for each one. All values should use ten spaces and be right justified. This assignment of for my computer science 121 class and it needs to be in C. I am totally lost on this one. Any suggestions would be greatly appreciated!!!!

Explanation / Answer

#include <stdio.h>

int main(void) {

int i,n,sum,max,min;

sum = 0;

//assign max and min to -50 and 50 ,allowed range

max = -50;

min = 50;

printf(" Input Values : ");

printf(" ");

for(i=1;i<=10;i++)

{

scanf("%d",&n);

if(i <10)

printf("%10d, ",n); //print , between numbers

else

printf("%10d ",n); // no comma , print new line

sum = sum + n; //running sum

if(n > max)

max = n;

if(n < min)

min = n;

}

printf(" The maximum number is %d",max);

printf(" The minimum number is %d",min);

printf(" Sum of all numbers is %d",sum);

printf(" The average of all numbers is %d",sum/10);

return 0;

}

output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote