Which of the following is TRUE about inline functions in C99 standard?
Answer: B
The 'inline' keyword is a hint to the compiler to replace function calls with the function body, reducing overhead but increasing code size.
Q.302Hard
What is function overloading in the context of C?
Answer: B
C does not support function overloading. To achieve similar functionality, use different names or variadic functions (using ...) or union of function pointers.
Q.303Easy
What is the return type of the strlen() function in C?
Answer: B
strlen() returns size_t, which is an unsigned integer type used to represent sizes and counts in C.
Q.304Medium
Which of the following correctly declares a function pointer that points to a function returning int and taking two int parameters?
Answer: A
The correct syntax for function pointer is return_type (*pointer_name)(parameter_types). Option A is correct.
Q.305Medium
In C, when a function is called with fewer arguments than declared, what happens?
Answer: D
Old-style K&R C declarations don't perform argument checking, allowing calls with fewer arguments. Modern prototyped functions generate compiler errors.
Advertisement
Q.306Easy
What is the scope of a function parameter in C?
Answer: C
Function parameters have function scope, meaning they are accessible throughout the entire function body.
Q.307Easy
Which keyword is used to create a function that can be expanded inline by the compiler without actual function call overhead?
Answer: C
The 'inline' keyword (introduced in C99) suggests to the compiler to replace function calls with actual code, reducing call overhead.
Q.308Medium
What will be printed by this code?
void func(int arr[10]) { printf("%lu", sizeof(arr)); }
int main() { int a[10]; func(a); }
Answer: C
When arrays are passed to functions, they decay to pointers. sizeof(arr) returns the size of the pointer, not the array.
Q.309Medium
What is the correct way to declare a function that accepts variable number of arguments?
Answer: D
Variadic functions require at least one named parameter before the ellipsis. Both options B and C follow the correct syntax.
Q.310Medium
Which of the following is true about a static function in C?
Answer: A
A static function has file scope and cannot be accessed from other translation units, providing encapsulation.
Q.311Medium
What happens if a function declared as returning int doesn't contain a return statement?
Answer: C
Without an explicit return statement, the function returns whatever value is in the return register, which is undefined behavior.
Q.312Easy
Consider: int func(int x) { return ++x; } What is the difference if we use x++ instead of ++x?
Answer: B
Pre-increment (++x) increments and returns the new value, while post-increment (x++) increments but returns the old value.
Q.313Medium
Which of the following correctly represents a callback function scenario?
Answer: B
A callback function is a function pointer passed to another function, which calls it at a later point in time.
Q.314Easy
What is the output of: int add(int a, int b) { int result = a + b; return result; } If called as add(5, 3)?
Answer: A
The function simply adds two integers and returns their sum, which is 5 + 3 = 8.
Q.315Hard
In C99 and later standards, what is the maximum number of parameters a function can have?
Answer: D
While C99 guarantees support for at least 127 parameters, the actual limit is implementation-dependent and varies by compiler.
Q.316Easy
What will be the output?
int func(int *p) { return *p; }
int main() { int x = 10; printf("%d", func(&x)); }
Answer: A
The function receives a pointer to x, dereferences it with *p, and returns the value 10.
Q.317Medium
Which of the following about function declaration and definition is TRUE?
Answer: B
Functions can have multiple forward declarations but only one definition. This allows function prototypes in header files.
Q.318Hard
What is the primary advantage of using function pointers in C?
Answer: B
Function pointers enable runtime polymorphism by allowing selection of which function to call based on runtime conditions.
Q.319Easy
In the context of recursion, which of the following is essential to avoid infinite recursion?
Answer: B
A base case is essential in recursive functions to provide a termination condition, otherwise the function will recurse infinitely.
Q.320Medium
What will happen when this code executes?
void func() { func(); } int main() { func(); }
Answer: A
This is infinite recursion with no base case, causing stack overflow as the function keeps calling itself.