Home / C Programming / Functions :: Function MCQs

C Programming :: Functions

  1. Which of the following is a complete function?

  2. A.

     int funct();

    B.

     int funct(int x) { return x=x+1; }

    C.

     void funct(int) { printf(“Hello"); }

    D.

     void funct(x) { printf(“Hello"); }

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. 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));

    }

  4. A.

     4 5 6 7

    B.

     1 2 3 4

    C.

     4

    D.

     Syntax error

    E.

     Runtime error

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. The recursive functions are executed in a ...........

  6. A.

     Parallel order

    B.

     First In First Out order

    C.

     Last In First Out order

    D.

     Iterative order

    E.

     Random order

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. The function scanf() returns .........

  8. A.

     The actual values read for each argument.

    B.

     1

    C.

     0

    D.

     The number of successful read input values.

    E.

     ASCII value of the input read.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Functions have ..........

  10. A.

     Local scope

    B.

     Block scope

    C.

     File scope

    D.

     Function scope

    E.

     No scope at all

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following function calculates the square of 'x' in C?

  12. A.

     sqr(x)

    B.

     pow(2, x)

    C.

     pow(x, 2)

    D.

     power(2, x)

    E.

     power(x, 2)

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. When a function is recursively called all the automatic variables are stored in a ..........

  14. A.

     Stack

    B.

     Queue

    C.

     Array

    D.

     Linked list

    E.

     Register

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. char* myfunc(char *ptr)

    {

    ptr+=3;

    return(ptr);

    }

    void main()

    {

    char *x, *y;

    x = "EXAMVEDA";

    y = myfunc(x);

    printf("y=%s", y);

    }

    What will be printed when the sample code above is executed?

  16. A.

     y=EXAMVEDA

    B.

     y=MVEDA

    C.

     y=VEDA

    D.

     y=EDA

    E.

     y=AMVEDA

    View Answer

    Workspace

    Discuss Discuss in Forum