AllInfoHub Logo

AllInfoHub – MCQ Practice

Functions – Multiple Choice Questions (MCQs)

  1. 1. What is a function in C?

    • A. A variable type
    • B. A block of code that performs a specific task
    • C. A loop structure
    • D. A data structure
  2. 2. What is function definition in C?

    • A. Specifying the function's return type and name
    • B. Calling the function
    • C. Providing the actual code that the function executes
    • D. Declaring the function
  3. 3. What is function call in C?

    • A. Defining the function's parameters
    • B. Specifying the return type
    • C. Executing the function
    • D. Declaring the function
  4. 4. Which keyword is used to return a value from a function in C?

    • A. exit
    • B. void
    • C. return
    • D. break
  5. 5. What is the return type of a function that does not return any value?

    • A. int
    • B. char
    • C. float
    • D. void
  6. 6. What are function parameters (arguments)?

    • A. Variables declared inside the function
    • B. Values passed to the function when it is called
    • C. The return value of the function
    • D. Keywords used in the function definition
  7. 7. What is the scope of a local variable declared inside a function?

    • A. Throughout the program
    • B. Only within the main function
    • C. Only within the function where it is declared
    • D. In all header files
  8. 8. What is a global variable in C?

    • A. A variable declared inside a function
    • B. A variable passed as an argument to a function
    • C. A variable declared outside any function
    • D. A variable with limited scope
  9. 9. What is the lifetime of a local variable in C?

    • A. Throughout the program execution
    • B. Only during the function call in which it is declared
    • C. Until the program terminates
    • D. It depends on where it is used
  10. 10. What is the purpose of function prototypes in C?

    • A. To define the function body
    • B. To call the function
    • C. To declare the function before its definition
    • D. To include header files
  11. 11. Which of the following is a valid function declaration in C?

    • A. void myFunction();
    • B. myFunction void;
    • C. function myFunction;
    • D. void function myFunction;
  12. 12. What is recursion in C?

    • A. A function that calls itself
    • B. A function that returns multiple values
    • C. A function with no parameters
    • D. A function defined inside another function