# Algorithms Quiz | Sudo Placement [1.5] | Question 8

• Last Updated : 16 Aug, 2018

Below is the code to find maximum subarray sum, with errors (which may results to wrong output) in the statement which is commented on right half after code statement. You need to choose the correct option for which corresponding statement is wrong.

 `#include``using namespace std;``  ` `// Function to calculate maximum subarray sum``int maxSubArraySum(int a[ ], int size)``{``   ``int max_so_far = a;``   ``int curr_max = a;``  ` `   ``for (int i = 1; i < size; i++)``   ``{``        ``curr_max = max(a[i], curr_max); // statement 1``        ``max_so_far = max(max_so_far, curr_max); // statement 2``   ``}``   ``return max_so_far;``}``  ` `/* Driver program to test maxSubArraySum */``int main()``{``   ``int a[] =  {-2, -3, 4, -1, -2, 1, 5, -3};``   ``int n = sizeof(a)/sizeof(a);``   ``int max_sum = maxSubArraySum(a, n);``   ``cout << "Maximum contiguous sum is " << max_sum;``   ``return 0;``}`

(A) Statement 1 and statement 2 both.
(B) Statement 1 only.
(C) Statement 2 only.
(D) Neither statement 1 nor statement 2.