Skip to content

Commit ea7678e

Browse files
committed
Create problem5.c
1 parent 077541f commit ea7678e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

problem5.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//Solved by S.Balakumar, CSE
2+
3+
#include<stdio.h>
4+
5+
int FindMaxSum(int arr[], int n)
6+
{
7+
int a = arr[0];
8+
int b = 0;
9+
int c;
10+
int i;
11+
12+
for (i = 1; i < n; i++)
13+
{
14+
15+
c = (a> b)?a: b;
16+
a = b + arr[i];
17+
b = c;
18+
}
19+
20+
21+
return ((a> b)? a : b);
22+
}
23+
24+
25+
int main()
26+
{
27+
int arr[] = {5, 5, 10, 100, 10, 5};
28+
printf("%d \n", FindMaxSum(arr, 6));
29+
getchar();
30+
return 0;
31+
}

0 commit comments

Comments
 (0)