Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would you solve this 2-D array lab using no global variables in c++ language

ID: 3812273 • Letter: H

Question

How would you solve this 2-D array lab using no global variables in c++ language ? A two-dimensional 6 x 8 array containing integers will have data from an input file. The input file has integers separated by spaces; the values are arranged in row-order. This means you read the values into the first row, then read values into the second row, and so on.) After input is done, output the array in table form (6 rows, 8 columns). Output is to the screen. Then do the following: Get user input of a row index (0 to 5). Calculate the sum of the elements in that row, and output it with a label, for the user to see (2) Get user input of a column index (0 to 7). Find the maximum value in the designated column, and output it with a label, for the user to see.

Explanation / Answer

#include<iostream>

#include<stdio.h>

using namespace std;

int main()

{

int a,b,sum=0,max=32684432;

cout<<endl;

printf("Enter the row index for sum: ");

cin<<a;

for(j=0;j<8;j++)

sum=sum+A[a][j];

printf("The sum is: ");

cout<<sum<<endl;

printf("Enter the column index for maximum element: ");

cin<<b;

for(j=0;j<6;j++) {

if(max<A[j][b])

max=A[j][b];

}

printf("The maximum element is: ");

cout<<max;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote