Consider the following function written in the C programming language. void…

GATE · 2015 · CS · Set 2 · Computer Science & IT

Consider the following function written in the C programming language.

void foo(char *a) {
    if (*a && *a != ' ') {
        foo(a+1);
        putchar(*a);
    }
}

The output of the above function on input “ABCD EFGH” is

  1. A.

    ABCD EFGH

  2. B.

    ABCD

  3. C.

    HGFE DCBA

  4. D.

    DCBA

Attempted by 305 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…