GATE CS 2015 Set 1 — Question 35

Numerical answer 2 marks Question 35 2015

Question 35

NAT 2 marks · no negative Programming and Data Structures

Consider the following function written in C:

int f(int n) {
    static int i = 1;
    if (n >= 5) return n;
    n = n + i;
    i++;
    return f(n);
}

The value returned by f(1) is ______.

Answers and explanations are free — they just need an account.

Where this question comes from

Source: GATE 2015 Computer Science and Information Technology, Set 1, Q35 (set and question number approximate)