Question: In C++ write a program that will create an array of integer numbers with a maximum size of 50. Then declare another variable N that

In C++ write a program that will create an array of integer numbers with a maximum size of 50. Then declare another variable N that represents how many actual numbers we are working with. Get an user input for N. Write a selection statement to check if N is less than 50, if it is more than 50, then display a message that N is crossing maximum size and ask the user to re-enter N.

Now write an input statement using a loop to get N number of integer values and store in the array.

Now find out the following from your program: (a) sum of all the numbers, (b) maximum value (c) minimum value and compute the average.

Code must display the sum, maximum, minimum and average. Average must be a float, and it should be displayed using one digit after the decimal.

In order to compute the sum, maximum and minimum, do the following:

Set sum = 0, maximum to INT_MIN and minimum to INT_MAX

Now write a loop with array index from 0 through N-1 and inside the loop, use

sum = sum + arrayName[i];

if (arrayName[i] > maximum) maximum = arrayName[i];

if (arrayName[i] < minimum) minimum = arrayName[i];

Then come out of the loop, and calculate the average by dividing sum by N, make sure to convert sum to a float value, this can be done by using float(sum)

Once the program works, next time change the data type for the array to a float and suitably change data types for sum, minimum, and maximum to floats and try running your program again.

Must make sure to save your first program (with integers) and then change to floats.

Please assist this is what I have so far but I am stuck.. This is for C++ beginner.

#include #include #include #include using namespace std;

const int maxSize=50;

int main() { int numbers[maxSize];//CHANGE INT TO FLOAT int N; //cout<< // GET USER INPUT FOR N

if (N > 50) {

cout<<"N value should be less than or equal to 50"<>N; int i; cout<<"Enter"<>numbers[i]; int sum, minimum, maximum; sum= 0; minimum=INT_MIN;//Change INT to FLOAT maximum=INT_MAX;//Change INT to float for (i=0;i<=N-1;i++) { sum=sum+numbers[i]; if (numbers [i]>maximum)maximum=numbers[i];

float average=float (sum)/N; //DISPLAY SUM, AVERAGE AND MIN, MAX

cout<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!