-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathQ2_Max_Sum_Of_Row.c
More file actions
50 lines (43 loc) · 810 Bytes
/
Q2_Max_Sum_Of_Row.c
File metadata and controls
50 lines (43 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Name :- Anand Patel Reg. No.:-AM.EN.U4CSE19206 Batch:- S2-CSE
#include<stdio.h>
void sums(int arr[100][100],int);
int main()
{
int arr[100][100]; //initializing 2D-Array
int lim;
int i,j;
printf("Enter the limit :");
scanf("%d",&lim);
printf("\n");
printf("Enter the 2D Array : \n");
for(i=0;i<lim;i++)
{
for(j=0;j<lim;j++)
{
scanf("%d",&arr[i][j]);
}
printf("\n");
}
sums(arr,lim);
}
void sums(int arr[100][100],int lim)
{
int i,j,s;
int a[100];
for(i=0;i<lim;i++)
{
s=0;
for(j=0;j<lim;j++)
{
s+=arr[i][j]; //sum of each row of 2D-Array
}
a[i]=s;
}
int l=0;
for(i=0;i<lim;i++)
{
if(a[i]>l) //checking for the maximum sum of the row from the 2D-Array
l=a[i];
}
printf("Highest Sum Of Row : %d\n",l);
}