Recursive Programs questions

Q35

GATE CS 2017 CS-1RecursionMCQ2 marks−2/3 if wrong
Consider the following two functions.
void fun1(int n) {
    if (n == 0) return;
    printf("%d", n);
    fun2(n - 2);
    printf("%d", n);
}

void fun2(int n) {
    if (n == 0) return;
    printf("%d", n);
    fun1(++n);
    printf("%d", n);
}
The output printed when fun1(5) is called is
Show answer without attempting

Answer: A

Q36

GATE CS 2017 CS-1RecursionMCQ2 marks−2/3 if wrong
Consider the C functions foo and bar given below:
int foo(int val) {
    int x = 0;
    while(val > 0) {
        x = x + foo(val--);
    }
    return val;
}

int bar(int val) {
    int x = 0;
    while(val > 0) {
        x = x + bar(val-1);
    }
    return val;
}
Invocations of foo(3) and bar(3) will result in:
Show answer without attempting

Answer: C

0/20 correct0 marks