What is the value printed by the following C program? #include<stdio.h> int…

GATE · 2010 · CS · Computer Science & IT

What is the value printed by the following C program?

#include<stdio.h>
int f(int *a, int n)
{
if (n <= 0) return 0;
else if (*a % 2 == 0) return *a+f(a+1, n-1);
else return *a - f(a+1, n-1);
}

int main()
{
int a[] = {12, 7, 13, 4, 11, 6};
printf("%d", f(a, 6));
return 0;
}

  1. A.

    -9

  2. B.

    5

  3. C.

    15

  4. D.

    19

Attempted by 108 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…