Question: Create a program in C++ to do the following: 1. Create 2d array 2. Find row sum 3. Find col sum 4. Find total sum

Create a program in C++ to do the following:

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Depending on the user's choice:

if 1. Create 2d array: create 2d array 3 rows by 4 columns filled with random numbers 1-10

if 2. Find row sum: ask row index and then print row sum

if 3. Find col sum: ask column index and then print column sum

if 4. Find total sum: print total sum

if 5. Find row with largest sum: ask row index and then print row number and sum

if 6. Find col with largest sum: ask column index and then print col number and sum

Use a loop and functions.

You should dispay the 2d array by row before displaying the menu as shown below. Your numbers may be different. The first time the array is empty []. Sample run:

[]

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7: 1

[7, 3, 7, 3] [6, 1, 9, 7] [9, 7, 9, 3]

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7: 2

Enter row index? 0-2: 1 The sum of all row 1 numbers is 23

[7, 3, 7, 3] [6, 1, 9, 7] [9, 7, 9, 3]

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7: 3

Enter column index? 0-3: 2 The sum of all column 2 numbers is 25

[7, 3, 7, 3] [6, 1, 9, 7] [9, 7, 9, 3]

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7: 4

The total sum is 71

[7, 3, 7, 3] [6, 1, 9, 7] [9, 7, 9, 3]

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7: 5

[7, 3, 7, 3] [6, 1, 9, 7] [9, 7, 9, 3] Row 2 has the largest sum 28

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7: 6

[7, 3, 7, 3] [6, 1, 9, 7] [9, 7, 9, 3]

Column 2 has the largest sum 25

1. Create 2d array

2. Find row sum

3. Find col sum

4. Find total sum

5. Find row with largest sum

6. Find col with largest sum

7. Quit

Please select 1-7 : 7

Goodbye!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!