What is the return type of a function that performs an action but doesn't return any value?
Answer: B
The void keyword is used as return type for functions that do not return any value.
Q.42Easy
In C, what happens when a function is called before its declaration?
Answer: B
C requires function declaration before use (forward declaration or definition). Calling without prior declaration causes compilation error in modern C standards.
Q.43Easy
Which of the following is an example of call by value in C?
Answer: B
Call by value passes a copy of the variable. Changes inside the function don't affect the original variable. Option B demonstrates this principle.
Q.44Easy
What is the main difference between function declaration and function definition?
Answer: A
Declaration (prototype) informs compiler about function signature; definition provides the actual implementation body.
Q.45Medium
Consider the code: int calculate(int a, int b = 5) { return a + b; }. What is the issue?
Answer: B
Default parameters are a C++ feature, not available in standard C. C requires explicit arguments for all parameters.
Advertisement
Q.46Medium
What will be the output of this recursive function? int fact(int n) { if(n <= 1) return 1; return n * fact(n-1); } fact(5)
Answer: C
This calculates factorial. fact(5) = 5*4*3*2*1 = 120. Base case n<=1 stops recursion.
Q.47Medium
Which statement about function parameters passed as arrays is correct?
Answer: B
Arrays in C decay to pointers to their first element, effectively making them pass-by-reference. Changes inside function affect original array.
Q.48Medium
What is the purpose of the 'extern' keyword when used with a function?
Answer: A
extern allows you to declare a function defined elsewhere, enabling its use across multiple translation units.
Q.49Medium
Consider: void modify(int *ptr) { *ptr = 20; } int main() { int x = 10; modify(&x); printf("%d", x); }. Output?
Answer: B
This is call by reference using pointers. The function receives address of x, dereferences and modifies it to 20.
Q.50Medium
What does variadic function mean in C?
Answer: A
Variadic functions accept variable number of arguments using ellipsis (...) and accessed with va_list, va_arg macros.
Q.51Medium
Which of the following correctly demonstrates inline function usage for optimization?
Answer: B
inline is a hint to compiler to expand function at call site. It's supported in C99+ and compiler decides whether to inline or not.
Q.52Hard
What will happen if a recursive function has no base case?
Answer: B
Without base case, recursion never stops, causing stack to overflow as return addresses keep accumulating.
Q.53Hard
Consider mutual recursion: void funcA(int n); void funcB(int n); funcA calls funcB and vice versa. What is required?
Answer: A
For mutual recursion, you need forward declaration (prototype) of at least one function before it's called by another.
Q.54Hard
What is the correct way to return multiple values from a function in C?
Answer: D
C doesn't support multiple return values. Both pointers (call-by-reference) and structs are valid techniques.
Q.55Hard
Analyze: int (*funcPtr)(int, int); What does this declaration represent?
Answer: B
The syntax (*funcPtr) indicates funcPtr is a pointer. It points to functions taking two ints and returning int.
Q.56Medium
What is the output of this 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); }
Answer: B
This is call-by-value. The function swaps copies of x and y, not the originals. Original values remain unchanged.
Q.57Hard
In C99 standard, what is true about function declarations at block scope?
Answer: B
C99 allows function declarations within blocks; they have scope limited to that block. This is different from function definitions which remain at file scope.
Q.58Hard
Which approach is more efficient for passing large structures to functions?
Answer: B
Passing large structures by pointer is more efficient as only address (typically 4-8 bytes) is copied, not entire structure.
Q.59Easy
What is the primary purpose of function prototypes in C?
Answer: A
Function prototypes inform the compiler about function name, return type, and parameters before the actual definition, enabling proper type checking during compilation.
Q.60Easy
Which of the following is a valid function declaration in C?
Answer: A
The correct syntax is return_type function_name(parameters). Option A follows proper C syntax with int as return type, func as name, and void indicating no parameters.