Hye..i dont know how to output the position for array.
Enter value for array A(4x5): 1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4Enter value for array B(4x5): 1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5The sum is: 2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9The highest value is 9 at row 3 and column 4.
#include<iostream>
using namespace std;
const int NUMBER_ROW=4;
const int NUMBER_COLUMNS=5;
int A[NUMBER_ROW][NUMBER_COLUMNS];
int B[NUMBER_ROW][NUMBER_COLUMNS];
int Total[NUMBER_ROW][NUMBER_COLUMNS];
int num;
int main(){
cout<<"Enter value for array A(4x5): ";
for(int i=0;i<4;i++){
for(int j=0;j<5;j++)
cin>>A[i][j];
}
cout<<"Enter value for array B(4x5): ";
for(int i=0;i<4;i++){
for(int j=0;j<5;j++)
cin>>B[i][j];
}
int sum=0;
for(int i=0;i<4;i++){
for(int j=0;j<5;j++)
Total[i][j]=A[i][j]+B[i][j];
}
int maxIndex1 = 0;
int maxIndex2 = 0;
for(int i=1;i<4;i++)
for(int j=1;j<5;j++)
if(Total[maxIndex1][maxIndex2]<Total[i][j])
Total[maxIndex1][maxIndex2]=Total[i][j];
int largest= Total[maxIndex1][maxIndex2];
cout<<"The sum is: "<<endl;
for(int i=0;i<4;i++){
for(int j=0;j<5;j++)
cout<<Total[i][j]<<" ";
cout<<endl;
}
//this part to brainstoming
cout<<"The largest is "<<largest<<" at row "<<Total[maxIndex1]<<" column "<<Total[maxIndex2];
return 0;
}