Where is my mistake?
You task is to find the column number(index) that have maximum sum of it's elements. Input First line N and M (1<=N,M<=100). Then NxM table is given(all number are integers) Output The index of the column with maximum sum of it's elements. Sample input: 3 4 1 2 3 1 1 5 6 1 1 1 8 1 Sample output: 3 #include <iostream> using namespace std; int main() { int a,b; cin >>a>>b; int arr[100][100]; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { cin >> arr[i][j]; } } int max = arr[0][0]; int x = 0; for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) { if (max < arr[i][j]) { max = arr[i][j]; x = i + 1; } } } cout << x; return 0; }