# Write a complete C++ program that does the following:1. Create a 2-dimensional array with 8 rows and 6 columns. Fill the array withrandom 3 digit integers.2. Create a function called findLargestSum which returns the sum of the row with thelargest sum.ex. int array = {{3, 6, 8}, // sum = 17{2, 4, 5}, // sum = 11{1, 0, 9}}; // sum = 10If the findLargestSum function was called using this array, it would return 17.Note that the number of columns is required when passing a 2d array to a functionint findLargestSum(int array[], int rows, int columns);

Question
2 views

Write a complete C++ program that does the following:
1. Create a 2-dimensional array with 8 rows and 6 columns. Fill the array with
random 3 digit integers.
2. Create a function called findLargestSum which returns the sum of the row with the
largest sum.
ex. int array = {{3, 6, 8}, // sum = 17
{2, 4, 5}, // sum = 11
{1, 0, 9}}; // sum = 10
If the findLargestSum function was called using this array, it would return 17.
Note that the number of columns is required when passing a 2d array to a function
int findLargestSum(int array[], int rows, int columns);

check_circle

Step 1

1)

Program plan:

• Declare the variables “rows” and “cols” as integer
• Assign “rows” to “8” and “cols” to “6”
• Initialize the random seed
• Loop to iterate the rows
• Loop to iterate the columns
• Generate the 3 digits random integer.

Step 2

Code:

//Declare and initialize the rows and columns
const int rows = 8;
const int cols = 6;
int arr[rows][cols];

//Initialize random seed:
srand(time(NULL));

//Loop to iterate the rows
for (int i = 0; i < rows; i++)
{
//Loop to iterate the column
for (int j = 0; j < cols; j++)
{
//generating 3 dight random integer
arr[i][j] = 100 + (rand() % 900);
}
}
Step 3

2)

Program plan:

• Include required packages
• Definition of function “findLargestSum(int arr[], int rows, int cols)”
• Find the largest sum of row values.
• Definition of function “display()”.
• Print the values.
• Declare the variables “rows” and “cols” as integer
• Assign “rows” to “8” and “cols” to “...

### 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

### Programing Language 