Functions in C Programming MCQ Questions and Answers

1. Which of the following is the correct syntax to declare a function in C?
A) return_type function_name();
B) function_name return_type();
C) function_name(); return_type
D) return_type = function_name();
Answer: A

2. A function that calls itself is known as:
A) Recursive Function
B) Iterative Function
C) Inline Function
D) Macro Function
Answer: A

3. What is the default return type of a function in C if not specified?
A) int
B) void
C) float
D) double
Answer: A

4. Which keyword is used to declare a function that returns no value?
A) null
B) void
C) empty
D) int
Answer: B

5. How can a function pass a variable so that the function can modify the original value?
A) Call by value
B) Call by reference
C) Call by name
D) Call by pointer only
Answer: B

6. Which of the following is not a valid way to call a function in C?
A) function_name();
B) function_name(arguments);
C) return_type function_name();
D) (*function_name)();
Answer: C

7. What will happen if a function is called before its declaration?
A) Compilation Error
B) Runtime Error
C) Works fine
D) Generates a warning but executes correctly
Answer: A

8. Which of the following is the correct way to define a function returning integer and taking no parameters?
A) int func(void) { }
B) func int() { }
C) void int func() { }
D) int func() { return; }
Answer: A

9. Which type of function in C does not return a value to the caller?
A) Non-returning function
B) Void function
C) Inline function
D) Recursive function
Answer: B

10. Which of the following is true about local variables inside a function?
A) They retain value between function calls
B) They are stored in static memory
C) They are destroyed after function execution ends
D) They are accessible globally
Answer: C

11. Which storage class is used for a variable inside a function to retain its value between calls?
A) auto
B) static
C) extern
D) register
Answer: B

12. Which function can be called before the main() function in C?
A) Any normal function
B) printf()
C) main() itself
D) void main()
Answer: C

13. Function prototypes in C are used for:
A) Declaring a function
B) Defining a function
C) Calling a function
D) Storing function variables
Answer: A

14. Which of the following statements about recursion is false?
A) Every recursive function must have a base case
B) Recursive functions always use more memory
C) Recursive functions cannot call other functions
D) Recursive functions can be used to solve factorials
Answer: C

15. What is the correct way to pass an array to a function in C?
A) function_name(array_name)
B) function_name(&array_name)
C) function_name(*array_name)
D) function_name(array_name[])
Answer: D

16. Inline functions in C are defined using which keyword?
A) inline
B) static
C) register
D) const
Answer: A

17. A function can return:
A) Only one value
B) Multiple values using return keyword
C) Multiple values using pointers or structures
D) Nothing
Answer: C

18. What is the scope of a function declared with static inside a file?
A) Accessible globally
B) Accessible only within the file
C) Accessible to other files using extern
D) Accessible outside function only
Answer: B

19. Function overloading is:
A) Supported in C
B) Not supported in C
C) Same as recursion
D) Same as inline function
Answer: B

20. Which of the following is true about main() in C?
A) Must always return int
B) Can have parameters argc and argv
C) Can be called recursively
D) All of the above
Answer: D

21. Which of the following is true about a function without parameters?
A) It cannot return a value
B) It can still return a value
C) It must be recursive
D) It cannot be called
Answer: B

22. A function that is declared but not defined will cause:
A) Compilation error
B) Runtime error
C) Warning only
D) No error
Answer: A

23. What happens when a function is called using call by value?
A) Original variable changes
B) Copy of variable is passed
C) Pointer of variable is passed
D) Function cannot access variable
Answer: B

24. Which of the following is used to return multiple values from a function?
A) Array
B) Pointer
C) Structure
D) All of the above
Answer: D

25. Which of the following is correct to declare a pointer to a function?
A) int (*p)();
B) int *p();
C) *int p();
D) p int*();
Answer: A

26. If a function returns void, it means:
A) The function returns zero
B) The function returns no value
C) The function must be recursive
D) The function cannot be called
Answer: B

27. What will be the output of this code?
void fun() { printf(“Hi”); }
int main() { fun(); return 0; }
A) Compilation Error
B) Runtime Error
C) Hi
D) Nothing
Answer: C

28. Which of the following is true about global variables and functions?
A) Functions cannot access global variables
B) Global variables cannot be used in functions
C) Functions can access global variables
D) Global variables are only for main()
Answer: C

29. What is the return type of the main() function in standard C?
A) void
B) int
C) float
D) double
Answer: B

30. Which of the following can be used to make a function inline?
A) inline keyword
B) register keyword
C) static keyword
D) auto keyword
Answer: A

31. Which of the following is not a valid function declaration?
A) int fun(int a);
B) void fun(void);
C) fun int(a);
D) int fun();
Answer: C

32. What is the storage duration of local variables inside a function?
A) Static
B) Automatic
C) External
D) Register
Answer: B

33. Which of the following allows a function to access a variable from another function?
A) Global variable
B) Static variable inside function
C) Local variable
D) Inline variable
Answer: A

34. If a function calls itself infinitely, it may cause:
A) Segmentation fault
B) Stack overflow
C) Compilation error
D) Linker error
Answer: B

35. What is the correct way to declare a function prototype?
A) return_type function_name(parameters);
B) function_name return_type(parameters);
C) return_type function_name[];
D) return_type function_name {};
Answer: A

36. Which of the following is true about recursive functions?
A) Always slow
B) Can replace iteration in some cases
C) Cannot return values
D) Must be void type
Answer: B

37. How many values can a function return directly in C?
A) 1
B) 0
C) Multiple
D) Infinite
Answer: A

38. Which of the following cannot be a function parameter?
A) Pointer
B) Array
C) Function itself
D) Structure
Answer: C

39. What is the advantage of using functions?
A) Reusability
B) Better organization
C) Debugging ease
D) All of the above
Answer: D

40. Which of the following is true about static functions?
A) Accessible only within the same file
B) Accessible globally
C) Cannot return a value
D) Must be inline
Answer: A

41. When a function is called, the execution:
A) Starts from main() only
B) Jumps to function, executes, and returns
C) Never returns
D) Starts in reverse order
Answer: B

42. Can a function return an array directly in C?
A) Yes
B) No
C) Only if static
D) Only if inline
Answer: B

43. What is the effect of return; in a void function?
A) Returns zero
B) Returns nothing and exits the function
C) Compilation error
D) Causes runtime error
Answer: B

44. Which of the following can be used to pass large data efficiently to a function?
A) Call by value
B) Call by reference
C) Recursive call
D) Inline call
Answer: B

45. Which of the following is correct for recursive factorial function call?
A) fact(n) = n * fact(n-1)
B) fact(n) = n + fact(n-1)
C) fact(n) = n / fact(n-1)
D) fact(n) = fact(n-1)
Answer: A

46. Which of the following is true about inline functions?
A) Always executed at runtime
B) Suggestion to compiler to replace function call with code
C) Cannot take parameters
D) Cannot return value
Answer: B

47. How is a function call resolved in C?
A) At runtime using stack
B) At compile time only
C) By preprocessor
D) By linker only
Answer: A

48. Which of the following is true about parameter passing in C?
A) Call by value passes address
B) Call by reference passes copy
C) Call by value passes copy
D) Call by value passes reference
Answer: C

49. Which of the following is true about recursion depth?
A) Unlimited
B) Limited by stack size
C) Always 10
D) Always 100
Answer: B

50. What is the difference between function declaration and function definition?
A) Declaration defines function body
B) Declaration only specifies signature
C) Declaration calls the function
D) There is no difference
Answer: B

51. Which of the following can return pointer to a function?
A) Function returning pointer type
B) Void function
C) Inline function
D) Recursive function
Answer: A

52. Can a function return a structure in C?
A) Yes
B) No
C) Only if global
D) Only if void
Answer: A

53. Which function call is faster?
A) Inline function
B) Recursive function
C) Normal function
D) Void function
Answer: A

54. Which storage class is default for local variables?
A) Auto
B) Static
C) Register
D) Extern
Answer: A

55. Which function can be used to terminate a program inside another function?
A) exit()
B) return()
C) void()
D) main()
Answer: A

56. What is the scope of a local variable inside a function?
A) Only inside function
B) Global
C) External
D) Across files
Answer: A

57. Can a function be passed as an argument in C?
A) No
B) Yes, using function pointer
C) Only inline
D) Only recursive
Answer: B

58. What is the role of return statement in a non-void function?
A) Ends function execution
B) Returns value to caller
C) Both A and B
D) None
Answer: C

59. Which of the following is true about call by reference?
A) Original value can be changed
B) Original value cannot be changed
C) Copies value only
D) Returns pointer only
Answer: A

60. Which of the following is not a correct function header?
A) int add(int, int);
B) void display(void);
C) float compute(float a, float b);
D) int sum() int a, int b;
Answer: D

61. Which of the following is true about default arguments in C?
A) Supported
B) Not supported
C) Only in main()
D) Only in void functions
Answer: B

62. Which of the following can be used to pass multi-dimensional array to a function?
A) Array of pointers
B) Pointer to array
C) Both A and B
D) None
Answer: C

63. What happens when a function is recursive without a base case?
A) Returns zero
B) Infinite recursion causing crash
C) Returns random value
D) Compilation error
Answer: B

64. What is the purpose of function prototypes?
A) Helps compiler check arguments
B) Optimizes code
C) Makes function inline
D) None
Answer: A

65. Which of the following statements is correct?
A) Global variables can be declared inside functions
B) Local variables can be accessed globally
C) Functions cannot access local variables of other functions
D) Static variables are destroyed after function call
Answer: C

66. Which of the following functions can be recursive?
A) Void function
B) Function returning int
C) Function returning pointer
D) All of the above
Answer: D

67. Which function calling method uses stack memory heavily?
A) Call by value
B) Call by reference
C) Recursive call
D) Inline call
Answer: C

68. Which of the following can be used to improve function performance?
A) Inline function
B) Recursive function
C) Large local variables
D) Global variables only
Answer: A

69. Which of the following is true about main() parameters?
A) int argc, char *argv[]
B) void main()
C) int main()
D) All of the above
Answer: D

70. Which of the following statements is false?
A) Functions can be nested in C
B) Functions cannot return arrays
C) Function pointers can store function addresses
D) Recursive functions must have a base case
Answer: A

71. What will be the output of this code?
void f(int x){ x=5; }
int main(){ int a=2; f(a); printf(“%d”,a); return 0; }
A) 2
B) 5
C) Compilation error
D) 0
Answer: A

72. Which function type allows reuse of code in multiple places?
A) Inline function
B) User-defined function
C) Recursive function
D) All of the above
Answer: B

73. Which of the following is true about void pointer as function argument?
A) Can point to any data type
B) Can store return address only
C) Cannot be passed to function
D) Only global variables
Answer: A

74. What is the default storage class for global variables?
A) Extern
B) Auto
C) Register
D) Static
Answer: A

75. Which of the following statements is correct about function arguments?
A) Number and type must match in call and declaration
B) Can be ignored
C) Can be more in call
D) None
Answer: A

76. Which of the following is true about recursive factorial function?
A) Uses stack memory
B) Slower than iterative version
C) Must have base case
D) All of the above
Answer: D

77. What is the difference between void and non-void function?
A) Void does not return value, non-void returns value
B) Void can return value
C) Non-void cannot return value
D) None
Answer: A

78. Which of the following is true about function pointers?
A) Can store address of a function
B) Cannot call function
C) Cannot be passed to function
D) Only works with void functions
Answer: A

79. Which of the following cannot be returned from a function in C?
A) int
B) float
C) Array
D) Structure
Answer: C

80. What will happen if a void function contains return 5;?
A) Compilation error
B) Returns 5 successfully
C) Runtime error
D) Warning only
Answer: A

81. Which of the following is true about inline functions?
A) Must be small
B) Cannot be recursive
C) Suggestion only, compiler may ignore
D) All of the above
Answer: D

82. Which of the following cannot be a function argument?
A) Pointer
B) Array
C) Function
D) Integer
Answer: C

83. How does call by reference improve performance?
A) Copies less data
B) Avoids function call
C) Saves memory in recursive calls
D) None
Answer: A

84. Which of the following is true about a function returning pointer?
A) Must not return local variable address
B) Can return global variable address
C) Can return dynamically allocated memory
D) All of the above
Answer: D

85. Which of the following can be used to terminate recursion?
A) Base case
B) Global variable
C) Inline function
D) Static variable
Answer: A

86. What is the effect of return; in main()?
A) Terminates program
B) Returns integer by default
C) Generates runtime error
D) Compiles but does not execute
Answer: B

87. Which of the following is true about function declaration without prototype?
A) Allowed in old C
B) Modern C requires prototype
C) Can cause implicit declaration warning
D) All of the above
Answer: D

88. Which of the following statements is false?
A) Functions can have same name if parameters differ in C
B) C does not support function overloading
C) Inline functions are hints only
D) Static functions are local to file
Answer: A

89. Which of the following statements is correct about recursive Fibonacci function?
A) Uses more memory than iterative
B) May be slower than iterative
C) Must have base case
D) All of the above
Answer: D

90. Which function type executes faster generally?
A) Inline
B) Normal
C) Recursive
D) Void
Answer: A

91. Which of the following is true about function definitions?
A) Must have name, return type, parameters, and body
B) Can have name only
C) Can omit return type
D) Can omit body
Answer: A

92. Which of the following is true about function calls?
A) Control jumps to function
B) Executes function body
C) Returns to calling function
D) All of the above
Answer: D

93. Which of the following is true about passing arrays to function?
A) Always pass by value
B) Decays to pointer
C) Cannot pass multi-dimensional array
D) Cannot modify original array
Answer: B

94. Which of the following is true about return in recursive functions?
A) Returns value to previous call
B) Terminates recursion
C) Both A and B
D) None
Answer: C

95. Which of the following is true about function headers?
A) Must match prototype
B) Must contain parameters in prototype
C) Return type is optional
D) Name is optional
Answer: A

96. Which of the following is true about call stack?
A) Stores function arguments
B) Stores local variables
C) Stores return addresses
D) All of the above
Answer: D

97. Which of the following is true about static local variables?
A) Retain value between calls
B) Reinitialized every call
C) Cannot be accessed outside function
D) Both A and C
Answer: D

98. Which of the following is true about external function definitions?
A) Can be in another file
B) Declared using extern
C) Accessible via header files
D) All of the above
Answer: D

99. Which of the following is true about function call by value?
A) Changes original variable
B) Passes copy only
C) Passes pointer
D) Always faster
Answer: B

100. Which of the following is true about main() function in C?
A) Can call other functions
B) Can be called recursively
C) Returns integer
D) All of the above
Answer: D