Question: Warning: do not use vectors in this exercise. Write a program that reads 16 integers into a 2D integer array with 4 rows and 4


Warning: do not use vectors in this exercise. Write a program that reads 16 integers into a 2D integer array with 4 rows and 4 columns, and performs the following tasks: (1) Reprint the 2D array (2) Accept user input of a character of either a 'c' or a 'r' AND an integer in the range of 0 to 3 and output the sum of all entries of a specified row ('r) or column (c) For example, if the user enters 5656c7461133954850 The program will output 5656746133954850 18 This is because the column 1 has entries 7,4,6, and 1. If instead the user enters 56743348 This is because the column 1 has entries 7,4,6, and 1. If instead the user enters 565657461033954850 The program will output 5656746133954850 19 This is because the row 0 has entries 5,7,3, and 4 . You can assume the input is always correct (always 16 integers, either ' c ' or ' r ', and the range is always from 0 to 3). You MUST write TWO functions to achieve the above task (2) - The first function will take the 2D array as input as well as an integer indicating a specific row index, and it will return the sum of the specified row using pass-by-reference. This function should have the following signature You can assume the input is always correct (always 16 integers, either ' c ' or ' r ', and the range is always from 0 to 3 ). You MUST write TWO functions to achieve the above task (2) - The first function will take the 2D array as input as well as an integer indicating a specific row index, and it will return the sum of the specified row using pass-by-reference. This function should have the following signature void calSum0fARow (int arr[4][4], int rowIndex, int \&sum); - The second function will take the 2D array as input as well as an integer indicating a specific column index, and it will return the sum of the specified column. This function should have the following signature int calSumOfAColumn (int arr[4] [4], int columnIndex); Hint Given a 2D array arr [4] [4], the entries of a specified row r are arr[r][0],arr[r][1], arr[r][2],arr[r][3]; and the entries of a specified column c are arr[0][c],arr[1][c], arr[2][c],arr[3][c]. Any attempt to hard code answers will result in a 0 for the exercise
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
