Home / C Programming / Functions :: Discussion

Discussion :: Functions

  1. What will be printed when this program is executed?

    int f(int x)

    {

    if(x <= 4)

    return x;

    return f(--x);

    }

    void main()

    {

    printf("%d ", f(7));

    }

  2. A.

     4 5 6 7

    B.

     1 2 3 4

    C.

     4

    D.

     Syntax error

    E.

     Runtime error

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    In this recursive function call the function will return to main caller when the value of x is 4. Hence the output.


Be The First To Comment