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

Create a program using C++(microsoft visual studios 2013) with comments that cre

ID: 3830693 • Letter: C

Question

Create a program using C++(microsoft visual studios 2013) with comments that creates a 3 x 5 two dimensional array and fills it with the following numbers in this order:

22, 40, 64, 92, 61, 42, 23,98, 85, 13, 81, 32, 90, 54, 16

and finds the following:

1)sum of the numbers

2)average of the numbers to 2 decimal places.

3)max value of the numbers

4)min value of the numbers

5)total count of the numbers greater than or equal to 50

you should first output the entire array then output the answers to the above 5 questions. Make sure output clearly identifies which answers are which.

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
int array[3][5] = {{22, 40, 64, 92, 61}, {42, 23,98, 85, 13}, {81, 32, 90, 54, 16}};
  
cout<<"Array elements are: "<<endl;
for(int i=0; i<3; i++){
for(int j=0; j<5; j++){
cout<<array[i][j]<<" ";
}
cout<<endl;
}
int sum =0;
double average;
int max = array[0][0];
int min = array[0][0];
int count =0;
for(int i=0; i<3; i++){
for(int j=0; j<5; j++){
if(max < array[i][j]){
max = array[i][j];
}
if(min > array[i][j]){
min = array[i][j];
}
  
sum = sum + array[i][j];
if(array[i][j] >= 50){
count++;
}
}

}
average = sum/(double)15;
cout<<"sum of the numbers: "<<sum<<endl;
cout<<fixed<<setprecision(2)<<"average of the numbers: "<<average<<endl;
cout<<"max value of the numbers: "<<max<<endl;
cout<<"min value of the numbers: "<<min<<endl;
cout<<"total count of the numbers greater than or equal to 50: "<<count<<endl;

return 0;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

Array elements are:                                                                                                                                                                                                                                                    

22 40 64 92 61                                                                                                                                                                                                                                                         

42 23 98 85 13                                                                                                                                                                                                                                                         

81 32 90 54 16                                                                                                                                                                                                                                                         

sum of the numbers: 813                                                                                                                                                                                                                                                

average of the numbers: 54.20                                                                                                                                                                                                                                          

max value of the numbers: 98                                                                                                                                                                                                                                           

min value of the numbers: 13                                                                                                                                                                                                                                           

total count of the numbers greater than or equal to 50: 8

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