Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2017 Set 1
Questions

Q36

MCQ2 marks, −0.67ProgrammingMedium

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)foo(3) and bar(3)bar(3) will result in:

Sign in to save attempts.

Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.