Test your understanding of C functions with these 15 multiple-choice questions — pass by value, function pointers, recursion, and static local variables. Every question has the answer and a short explanation hidden below it, and the trickier ones link to a full walkthrough with compilable code.
These questions come from our free Android app, C Programming Quiz — 150+ questions across 9 categories with score tracking, if you prefer to practise on your phone.
How to use this page: answer each question yourself before tapping Show answer. If you get one wrong, follow the linked explanation — knowing why the wrong options are wrong is what interviews test.
Question 1 of 15 (Easy)
How are arguments passed to functions in C by default?
- By value
- By reference
- By name
- By pointer automatically
Show answer
Answer: A — By value
C always passes arguments by value — the function receives a copy. To modify a caller's variable you pass a pointer to it.
Question 2 of 15 (Easy)
What return type indicates that a function returns no value?
- null
- void
- int
- empty
Show answer
Answer: B — void
'void' as a return type means the function does not return a value.
Question 3 of 15 (Medium)
What is most likely to happen if a recursive function has no base case?
- It returns 0
- Infinite recursion and a stack overflow
- A compile error
- It runs exactly once
Show answer
Answer: B — Infinite recursion and a stack overflow
Without a base case the recursion never stops, consuming stack frames until the stack overflows and the program crashes.
Question 4 of 15 (Hard)
What is printed if f() is called three times in a row?
void f(void) {
static int c = 0;
c++;
printf("%d", c);
}
- 000
- 111
- 123
- 333
Show answer
Answer: C — 123
A static local variable keeps its value between calls and is initialized only once. c becomes 1, then 2, then 3 — printing 123.
Full walkthrough with compilable code: read the detailed explanation.
Question 5 of 15 (Medium)
What is the output of this code?
int add(int a, int b) { return a + b; }
printf("%d", add(3, 4));
- 7
- 34
- 0
- Compile error
Show answer
Answer: A — 7
add receives copies of 3 and 4, computes 3 + 4 = 7, and returns it. printf prints 7.
Full walkthrough with compilable code: read the detailed explanation.
Question 6 of 15 (Hard)
What is the output of this code?
void inc(int x) { x++; }
int n = 5;
inc(n);
printf("%d", n);
- 6
- 5
- Compile error
- Undefined behavior
Show answer
Answer: B — 5
C passes by value. inc receives a copy of n and increments the copy. n in the caller remains 5.
Full walkthrough with compilable code: read the detailed explanation.
Question 7 of 15 (Medium)
What is a function prototype used for?
- To allocate memory for the function
- To declare a function's return type and parameter types before its definition
- To call the function
- To define the function body
Show answer
Answer: B — To declare a function's return type and parameter types before its definition
A function prototype (declaration) tells the compiler the function's return type and parameter types so it can type-check calls before seeing the full definition.
Question 8 of 15 (Hard)
What does the 'inline' keyword hint to the compiler?
- The function must be inlined — it is mandatory
- The function body should be substituted at call sites to avoid call overhead
- The function is recursive
- The function has no side effects
Show answer
Answer: B — The function body should be substituted at call sites to avoid call overhead
'inline' is a hint — the compiler may choose to substitute the function body at each call site, eliminating call overhead. It is not a mandate; the compiler can ignore it.
Question 9 of 15 (Easy)
Which header must you include to use printf?
- stdlib.h
- stdio.h
- string.h
- math.h
Show answer
Answer: B — stdio.h
printf and other standard I/O functions are declared in <stdio.h>.
Question 10 of 15 (Hard)
What does this function pointer call do?
int add(int a, int b) { return a + b; }
int (*op)(int, int) = add;
printf("%d", op(3, 4));
- Compile error
- 7
- 34
- Undefined behavior
Show answer
Answer: B — 7
op is a function pointer assigned to add. op(3, 4) calls add(3, 4) which returns 7.
Question 11 of 15 (Medium)
What does 'static' mean when applied to a function?
- The function is called once
- The function has internal linkage — it is not visible outside its translation unit
- The function's local variables persist between calls
- The function cannot be recursive
Show answer
Answer: B — The function has internal linkage — it is not visible outside its translation unit
A 'static' function has internal linkage: it can only be called from within the same .c file. This is a common way to make helper functions private.
Question 12 of 15 (Hard)
What is variadic function support in C, and what header enables it?
- Functions with variable return types; <typedefs.h>
- Functions accepting a variable number of arguments; <stdarg.h>
- Functions that vary their behavior at runtime; <stdlib.h>
- Recursive functions with variable depth; <setjmp.h>
Show answer
Answer: B — Functions accepting a variable number of arguments; <stdarg.h>
C supports variadic functions (like printf) that accept a variable number of arguments. <stdarg.h> provides va_list, va_start, va_arg, and va_end to access the extra arguments.
Question 13 of 15 (Medium)
What is the purpose of 'argc' in 'int main(int argc, char *argv[])'?
- The number of bytes in argv
- The count of command-line arguments (including the program name)
- The return code of the last system call
- The size of the program
Show answer
Answer: B — The count of command-line arguments (including the program name)
argc (argument count) is the number of command-line arguments passed to the program. argv[0] is the program name, so argc is at least 1.
Question 14 of 15 (Easy)
What does the 'return' statement do in a function?
- Jumps to the next function
- Exits the function and optionally returns a value to the caller
- Restarts the function from the beginning
- Exits the program
Show answer
Answer: B — Exits the function and optionally returns a value to the caller
return exits the current function and passes a value back to the caller. In void functions, return can be used without a value.
Question 15 of 15 (Hard)
What is the output of this code?
int fact(int n) {
return n <= 1 ? 1 : n * fact(n - 1);
}
printf("%d", fact(5));
- 60
- 120
- 24
- Compile error
Show answer
Answer: B — 120
fact(5) = 5 * 4 * 3 * 2 * 1 = 120.
Full walkthrough with compilable code: read the detailed explanation.
How Did You Score?
All 15 correct means this topic is interview-ready — try the harder timed rounds in the C Programming Quiz app. Missed a few? The guides below cover everything these questions test.
Keep Practising
- Function Pointers in C
- Recursion in C — A Complete Guide
- Pass by Value in C
- All quiz question walkthroughs
More C Quizzes
- C Basics Quiz — 28 Questions with Answers
- C Operators Quiz — 20 Questions with Answers
- C Memory Management Quiz — 19 Questions with Answers
- C Pointers Quiz — 18 Questions with Answers
- C Arrays and Strings Quiz — 18 Questions with Answers
- C Structs and Unions Quiz — 13 Questions with Answers
- C File I/O Quiz — 13 Questions with Answers
- C Preprocessor Quiz — 11 Questions with Answers