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

Create a program that will allow the user to input a maximum of ten integer valu

ID: 3548566 • Letter: C

Question

Create a program that will allow the user to input a maximum of ten integer values (these values will be stored in an array .  The program will then find the maximum value entered, find the minimum value entered, and calculate the total value of all integers entered. Output will be all inputs and calculated values. Use a SEPARATE LOOP for each task. Use looping structures for: Input Find maximum Find Minimum Calculate Total Output Create a program that will allow the user to input a maximum of ten integer values (these values will be stored in an array .  The program will then find the maximum value entered, find the minimum value entered, and calculate the total value of all integers entered. Output will be all inputs and calculated values. Use a SEPARATE LOOP for each task. Use looping structures for: Input Find maximum Find Minimum Calculate Total Output

Explanation / Answer

//in cpp


#include<iostream>

using namespace std;


int main(){


//variables

int myArr[10];//10 element array

int min,max;

int total=0; //make sure to initialize

int input;


//get the numbers

for(int i=0;i<10;i++){ //note that count starts at 0, not 1

cout<<"Enter an integer: ";

cin>>myArr[i];

}


//find max

max=myArr[0]; //assume max is first element

for(int i=1;i<10;i++){//looking for a new max

if(max<myArr[i]){//if new max found,

max=myArr[i]; //set max to it

}

}


//find min

min=myArr[0]; //assume min is first element

for(int i=1;i<10;i++){//looking for a new min in rest of array

if(min>myArr[i]){//if new min found,

min=myArr[i]; //set min to it

}

}


//calculate total

for(int i=0;i<10;i++){

total+=myArr[i];

}



//outputing

cout<<"The numbers entered: ";

for(int i=0;i<10;i++){

cout<<myArr[i]<<" ";

}

cout<<endl<<endl<<"Max: "<<max<<endl;

cout<<"Min: "<<min<<endl;

cout<<"Total: "<<total;


cin>>input; //this is just to stop auto exiting of console until something is entered

return 0;

}

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