PRACTICE • LEARN • GROW
Module 5: Functions & Recursion - Final Quiz MCQs
Solve topic-wise placement questions and improve your skills.
Module 5: Functions & Recursion - Final Quiz Progress
0 of 9 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
In standard C, which parameter passing mechanism is strictly used for all primitive function arguments?
A.
Call by Reference
B.
Call by Value
C.
Call by Name
D.
Call by Copy-Restore
Explanation & Key
Correct Answer:
2
What is the output of the following attempt to swap two variables?
#include <stdio.h>
void swap(int x, int y) {
int temp = x;
x = y;
y = temp;
}
int main() {
int a = 10, b = 20;
swap(a, b);
printf("%d %d", a, b);
return 0;
}
A.
20 10
B.
10 20
C.
0 0
D.
Compile error
Explanation & Key
Correct Answer:
3
What is the output of the following recursive function?
#include <stdio.h>
void countBack(int n) {
if (n == 0) return;
countBack(n - 1);
printf("%d ", n);
}
int main() {
countBack(3);
return 0;
}
A.
3 2 1
B.
1 2 3
C.
3 2 1 0
D.
0 1 2 3
Explanation & Key
Correct Answer:
4
What is the output of this code utilizing a static local variable?
#include <stdio.h>
void counter() {
static int c = 0;
c++;
printf("%d ", c);
}
int main() {
counter();
counter();
counter();
return 0;
}
A.
1 1 1
B.
1 2 3
C.
0 1 2
D.
3 3 3
Explanation & Key
Correct Answer:
5
What severe memory bug exists in the following function?
int* createNumber() {
int num = 42;
return #
}
A.
Syntax error because functions cannot return pointer types
B.
It returns the address of a local stack variable that is deallocated when the function returns (dangling pointer)
C.
It produces a heap memory leak
D.
It causes integer overflow
Explanation & Key
Correct Answer:
6
What is a "tail recursive" function?
A.
A recursive function that has no base case
B.
A recursive function where the recursive call is the very last operation executed before returning
C.
A function that takes another function pointer as an argument
D.
A function that returns a void pointer
Explanation & Key
Correct Answer:
7
What happens when recursion fails to reach or execute a base case?
A.
The function automatically returns 0
B.
The compiler issues a warning and converts it to a while loop
C.
Stack Overflow exception / Segmentation Fault due to exhaustion of available stack memory
D.
Heap fragmentation
Explanation & Key
Correct Answer:
8
What does the C standard state regarding the order of evaluation of arguments passed to a function call (e.g.
func(a(), b()))?
A.
Guaranteed strictly left-to-right
B.
Guaranteed strictly right-to-left
C.
Unspecified by the C standard
D.
Alphabetical based on function name
Explanation & Key
Correct Answer:
9
Which of the following information is NOT typically stored inside a function activation record (stack frame)?
A.
Return address to the caller
B.
Local variables declared inside the function
C.
Passed parameter values
D.
Dynamically allocated memory created with malloc()
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong