TPS 7: 2D arrays
- Due Mar 19, 2021 by 10am
- Points 1
- Submitting a file upload
- File Types doc and docx
- Available after Mar 19, 2021 at 9am
Write the C++ for the pseudo code on lines 20–24 in the program below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
#include <iostream> using namespace std; int main(){ const int STUDENTS = 3; const int ASSIGNMENTS = 5; int scores[STUDENTS][ASSIGNMENTS] = { {85, 82, 80, 78, 88}, {90, 95, 92, 87, 93}, {45, 67, 50, 46, 70} } ; double averageScore; int sum = 0; // To find the macro-average: // 1. sum all numbers in scores // 2. divide the sum by the number of elements in scores (STUDENTS*ASSIGNMENTS) // for each row index i between 0 and STUDENTS: // for each column index j between 0 and ASSIGNMENTS: // increase sum by scores[i][j] // set averageScore to sum / number of elements in scores cout << "Average assignment score: " << averageScore << endl; return 0; } |
After we've completed the group share portion, upload a copy of your updated TPS document.