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

You are required to write a program in C++ that reads a list of (non-zero) integ

ID: 3626707 • Letter: Y

Question

You are required to write a program in C++ that reads a list of (non-zero) integers from the standard input device, and calculates and displays the difference of between the largest and the smallest of these values. The program will end when a 0 value is read.

Also write another program that C++ to read a series of positive integers from the keyboard (treated as the standard input device), until a non-positive number (0,
or negative number) is read. Compute and display the average of those positive numbers that are read. Obviously we exclude the last non-positive number from the total and average calculation. Also please write algorithm after.

Explanation / Answer

Is the imput suposed to be entered all in one line or mutiples lines? int MaxMin(){ int n; int max = 0; int min = 0; Printf("List of intigers :"); (scanf("%d",&n); while ( n != 0){ if ( max == 0) min = max = n; // i'm assuming you can't ever have the value 0, otherwise you'll have to change the inicial values of max and min else if ( n > max) max = n; else if ( n 0){ n++; total += x; (scanf("%d",&x); } doube average = (double) total / n; printf(" average is %d ",average); } this is more C than C++ but if you change the input functions to cin and cout it's the same thing, didn't tested so it might be buggy but the basis is there