GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2020

GATE 2020 · CS · NAT · 2 marks · Programming and Data Structures › C Programming Fundamentals

GATE 2020 Computer Science and Information Technology question: Consider the following C functions. code code The return value of fun2(5) is .

Consider the following C functions.

int fun1(int n) {
    static int i = 0;
    if (n > 0) {
        ++i;
        fun1(n-1);
    }
    return(i);
}
int fun2(int n) {
    static int i = 0;
    if (n > 0) {
        i = i + fun1(n);
        fun2(n-1);
    }
    return(i);
}

The return value of fun2(5) is _________.

Show answer

Official answer: 55

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion