What Is The Value Stored In Sum4 After The Following Program Is #1998

What is the value stored in sum[4] after the following program is executed?</p> <pre><code class="language-cpp"> #include<stdio.h> int max_num(int a,int b) { if(a> b) return a; return b; } int maximum_subarray_sum(int *arr, int len) { int sum[len], idx; sum[0] = arr[0]; for(idx = 1; idx < len; idx++) sum[idx] = max_num(sum[idx - 1] + arr[idx], arr[idx]); int mx = sum[0]; for(idx = 0; idx < len; idx++) if(sum[idx] > mx) mx =sum[idx]; return mx; } int main() { int arr[] = {-2, 14, 11, -13, 10, -5, 11, -6, 3, -5},len = 10; int ans = maximum_subarray_sum(arr, len); printf("%d",ans); return 0; }</code></pre>

Online Quiz This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Dynamic Programming - Maximum Sum of Continuous Subarray - Quiz No.1.


Similar question(s) are as followings:



Online Quizzes of gs122 Data Communication and Computer Network

Choose an organization

Theme Customizer

Gaussian Texture



Gradient Background