AllInfoHub Logo

AllInfoHub – MCQ Practice

Functions – Multiple Choice Questions (MCQs)

  1. 37. Can you overload functions in C (have multiple functions with the same name but different parameters)?

    • A. Yes
    • B. No
    • C. Only with different return types
    • D. Only if they are static
  2. 38. What is the purpose of using header files for function declarations?

    • A. To make the function definitions available
    • B. To allow separate compilation of code
    • C. To improve code readability and organization
    • D. All of the above
  3. 39. What is the difference between declaring a function and defining a function?

    • A. Declaration specifies the interface
    • B. definition provides the implementation
    • C. Declaration provides the implementation
    • D. definition specifies the interface
  4. 40. What is the advantage of modular programming using functions?

    • A. Code reusability
    • B. Improved code organization
    • C. Easier debugging and maintenance
    • D. All of the above
  5. 41. What is a side effect of a function?

    • A. Any output produced by the function
    • B. Any modification of variables outside the function's scope
    • C. The return value of the function
    • D. The execution time of the function
  6. 42. What is a pure function?

    • A. A function with no return value
    • B. A function that always produces the same output for the same input and has no side effects
    • C. A function that modifies global variables
    • D. A recursive function
  7. 43. What is the purpose of the 'static' keyword when used with a global function?

    • A. To make the function inline
    • B. To limit the function's scope to the file in which it is defined
    • C. To store the function in static memory
    • D. To make the function recursive
  8. 44. What is the difference between calling a function by value and calling a function by reference?

    • A. Call by value passes a copy
    • B. call by reference passes the original address
    • C. Call by reference passes a copy
    • D. call by value passes the original address
  9. 45. What is the output of the following code? `int multiply(int a, int b) { a = a * 2; return a * b; } int main() { int x = 3, y = 4; int result = multiply(x, y); printf(\%d %d %d\"",x,y,result); return 0; }`"""

    • A. 3 4 24
    • B. 6 4 24
    • C. 3 8 24
    • D. 6 8 48
  10. 46. What is the output of the following code? `void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int main() { int x = 5, y = 10; swap(&x, &y); printf(\%d %d\"",x,y); return 0; }`"""

    • A. 5 10
    • B. 10 5
    • C. 5 5
    • D. 10 10
  11. 47. Can a function call itself indirectly (through another function)?

    • A. Yes
    • B. No
    • C. Only if it's a global function
    • D. It depends on the compiler
  12. 48. What is the maximum number of arguments a function can have in C?

    • A. No fixed limit
    • B. Limited by memory
    • C. 255
    • D. Depends on the compiler