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 4

Enter value for array B(4x5): 1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

The sum is: 2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9

The 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;    
    }

Close. You need to update your indices:

#include <iostream>

int main()
{
    int a[][3] = {
        {5, 3, 6},
        {7, 2, 4},
        {8, 9, 1}
    };
    int row = 0, col = 0;

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (a[i][j] > a[row][col]) {
                row = i;
                col = j;
            }
        }
    }

    std::cout<<"The largest is "<< a[row][col] <<" at row "<< row <<" column "<< col <<'\n';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.