Question
Asked Dec 12, 2019
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

Expert Answer

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

Check out a sample Q&A here.

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

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Consider a schema  R={A,B,C,D,E} and the following set of functional dependencies: {AB-&gt; C, C-&gt...

A: To find whether the relation is in BCNF or not, it must fulfill all the conditions given below-1)Rel...

question_answer

Q: What is the difference between hexanumber and ascii code

A: Warm-up description –ASCII code –ASCII stands for American Standard Code for Information Interchange...

question_answer

Q: I have having some confusion as to what exactly the defintion of  "special operator in the condition...

A: The Definition of “Special Operator in The Conditional Expression” is:In the question a query based ...

question_answer

Q: C++

A: Infix to Postfix: At the time of conversion from infix to postfix, divide the whole expression into ...

question_answer

Q: Do the following program in Java Eclipse:A veterinarian services many pets and their owners. As new ...

A: Program Instructions:Create a java program in eclipse and import all required modules.Now create a m...

question_answer

Q: Compiler returning errors with calculations and declarations. Screenshot of File.txt included.  ...

A: The code is working fine as I have tested it and the Output is attached at the end.Code://importing ...

question_answer

Q: 1. Write a program in python with no imports named filemaker.py that will be used to store the first...

A: The name of the program is filereader.pyOpen the file named friends.txtUse a variable named accumula...

question_answer

Q: The prompt asks me to write a program that asks the user to enter an object’s mass, then calls a fun...

A: Program Algorithm-STARTStep1: Import the essential java packages.Step2: Define the class Main.Step3:...

question_answer

Q: write a c++ program that sssign numItems' address to numItemsPtr, then print the shown text followed...

A: Program Code: