Home / C Programming / Functions :: Function MCQs

C Programming :: Functions

  1. What will happen after compiling and running following code?

    main()

    {

    printf("%p", main);

    }

  2. A.

     Error

    B.

     Will make an infinite loop.

    C.

     Some address will be printed.

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Use of functions

  4. A.

     Helps to avoid repeating a set of statements many times.

    B.

     Enhances the logical clarity of the program.

    C.

     Helps to avoid repeated programming across programs.

    D.

     Makes the debugging task easier.

    E.

     All of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Any C program

  6. A.

     Must contain at least one function.

    B.

     Need not contain any function.

    C.

     Needs input data.

    D.

     None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is function?

  8. A.

     Function is a block of statements that perform some specific task.

    B.

     Function is the fundamental modular unit. A function is usually designed to perform a specific task.

    C.

     Function is a block of code that performs a specific task. It has a name and it is reusable.

    D.

     All of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Determine output:

    main()

    {

    int i = abc(10);

    printf("%d", --i);

    }

    int abc(int i)

    {

    return(i++);

    }

  10. A.

     10

    B.

     9

    C.

     11

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. The default parameter passing mechanism is

  12. A.

     call by value

    B.

     call by reference

    C.

     call by value result

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the result of compiling and running this code?

    main()

    {

    char string[] = "Hello World";

    display(string);

    }

    void display(char *string)

    {

    printf("%s", string);

    }

  14. A.

     will print Hello World

    B.

     Compilation Error

    C.

     will print garbage value

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Determine output:

    main()

    {

    int i = 5;

    printf("%d%d%d%d%d", i++, i--, ++i, --i, i);

    }

  16. A.

     54544

    B.

     45445

    C.

     54554

    D.

     45545

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Pick the correct statements.
    I.   The body of a function should have only one return statement.
    II.  The body of a function may have many return statements.
    III. A function can return only one value to the calling environment.
    IV. If return statement is omitted, then the function does its job but returns no value to the calling environment.

  18. A.

     I and II

    B.

     I and III

    C.

     II and III

    D.

     II and IV

    E.

     III and IV

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the following program code?

    main()

    {

    static int var = 5;

    printf("%d ", var--);

    if(var)

    main();

    }

  20. A.

     5 5 5 5 5

    B.

     5 4 3 2 1

    C.

     Infinite Loop

    D.

     Compilation Error

    E.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum