Consider the program below: #include <stdio.h> int fun(int n, int *f_p) { int…

GATE · 2009 · CS

Consider the program below:

#include <stdio.h>
int fun(int n, int *f_p) {
    int t, f;
    if (n <= 1) {
        *f_p = 1;
        return 1;
    }
    t = fun (n-1, f_p);
    f = t + *f_p;
    *f_p = t;
    return f;
}
int main() {
    int x = 15;
    printf ("%d\n", fun(5, &x));
    return 0;
}

The value printed is:

  1. A.

    6

  2. B.

    8

  3. C.

    14

  4. D.

    15

Attempted by 58 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…