# Question 2. Write a complete C++ program that uses a 2-dimensional array with 4 rows and 30 columns. Row represents sections of a course and column represents the students, value inside each position of the array is the final exam grade for each students. Fill the array with random numbers between 40 and 100. Calculate the total, average, maximum, minimum for each section.

Question
2 views

Question 2. Write a complete C++ program that uses a 2-dimensional array with 4 rows and 30 columns. Row represents sections of a course and column represents the students, value inside each position of the array is the final exam grade for each students. Fill the array with random numbers between 40 and 100. Calculate the total, average, maximum, minimum for each section.

check_circle

Step 1

Program Instructions:

• In main, declare an array and call function fillarray() that fills the array with 4*30 elements between 40 and 100 random numbers.
• Use variables total, min and max to calculate the total, min and max for each section using a for loop.
• Display the total, min and max and average each section.
Step 2

Program:

#include<iostream>

#include<ctime>

#include<cstdlib>

using namespace std;

void fillArray(int scores[][30], int courses){

srand(time(NULL));

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

for(int student=0; student<30; student++){

// Fill the array with random numbers between 40 and 100

scores[i][student] = 40+rand()%61;

}

}

}

int main(){

// Row represents sections of a course and column represents the students,

const int COURSES=4;

const int STUDENTS=30;

// a 2-dimensional array with 4 rows and 30 columns

int scores[COURSES][STUDENTS];

fillArray(scores,COURSES);

// value inside each position of the array is the final exam grade for each students

for(int course=0; course<COURSES;course++){

int total=0;

int min =scores[course][0];

int max =scores[course][0];

&nb...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in