**(HackerRank) Write a Modular C Programming code to solve Maximum sum 16, Given a matrix of order R * C, display all the column numbers that have the maximum sum**

Given a matrix of order R * C, display all the column numbers that have a maximum sum

**Input Format**

The first line contains two integers R and C, the order of the matrix separated by a space.

The next line contains R * C integers separated by a space

**Constraints**

1<= R,C<=100

**Output Format**

In one display all the column numbers in each line that have maximum sum

Note: Column number starts from zero.

**Sample Input 0**

```
0 5
```

**Sample Output 0**

```
Invalid
```

**Sample Input 1**

```
3 3
2 2 3 9 5 6 7 8 9
```

**Sample Output 1**

```
0
2
```

**Explanation 1**

```
Sum of 0th Col = 18
Sum of 1st Col = 15
Sum of 2nd Col = 18
```

**CODE:**

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int r,c; scanf("%d%d",&r,&c); if(r>1 && c>1) { int num[r][c],i,j,colsum[c]; for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&num[i][j]); } } for(i=0;i<c;i++) { colsum[i]=0; for(j=0;j<r;j++) { colsum[i]+=num[j][i]; } } int max=colsum[0]; for(i=0;i<c;i++) { if(max<colsum[i]) max=colsum[i]; } for(i=0;i<c;i++) { if(max==colsum[i]) printf("%d\n",i); } } else{ printf("Invalid"); } return 0; } }

**OUTPUT**

Congratulations, you passed the sample test case. Click the Submit Code button to run your code against all the test cases. Input (stdin) 0 5 Your Output (stdout) Invalid Expected Output Invalid

**Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, Stacks, Queues, Binary Trees, MISC, Solved model question papers & Hacker Rank all solutions on the below page:**