Back to Browse

Gate 2007 pyq C Programming | Consider the C program given below :int main (){int sum = 0, maxsum

694 views
Nov 1, 2022
10:17

Consider the C program given below : #include stdio.h int main () { int sum = 0, maxsum = 0, i, n = 6; int a [] = {2, -2, -1, 3, 4, 2}; for (i = 0; i less_than n; i++) { if (i == 0 || a [i] less_than 0 || a [i] less_than a [i - 1]) { if (sum greater_than maxsum) maxsum = sum; sum = (a [i] greater_than 0) ? a [i] : 0; } else sum += a [i]; } if (sum greater_than maxsum) maxsum = sum ; printf ("%d\n", maxsum); } What is the value printed out when this program is executed? (A) 9 (B) 8 (C) 7 (D) 6

Download

1 formats

Video Formats

360pmp429.3 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Gate 2007 pyq C Programming | Consider the C program given below :int main (){int sum = 0, maxsum | NatokHD