Home / MCQ Bank / Computer
Computer Dynamic Programming In Data Structures Difficulty: Medium

What is the output of the following program? #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[] = {-20, 23, 10, 3, -10, 11, -5},len = 7; int ans = maximum_subarray_sum(arr, len); printf("%d",ans); return 0; }

Select the correct option to test your answer:

More Computer Questions

Which of the following methods must empty the list of subpaths so that the context once again has zero subpaths? What will be the output of the following C# code snippet? class Program { static void Main(string[] args) { int[] nums = {1}; var posNums = from n in nums wheres n > 0 select Math.Max(78, 9); Console.Write("The largest values in nums: "); foreach (int i in posNums) Console.Write(i + " "); Console.WriteLine(); Console.ReadLine(); } } Which of these methods deletes all the elements from invoking collection? What will be the output of the following Python code? import turtle t=turtle.Pen() t.resizemode(“examveda”) t.resizemode() In Hive, what is the significance of the WHERE clause in a SELECT statement?