Govt. Exams
Entrance Exams
Without a base case, recursion never terminates. Each function call pushes data onto the stack. Eventually, the stack memory is exhausted, causing a stack overflow error. This is a runtime error, not a compile-time error.
When an array is used as a function parameter, it undergoes array-to-pointer decay, converting to a pointer to the first element. This is why size information is lost.
A callback is a function pointer passed to another function, which then invokes it at some point. Callbacks are essential for event-driven programming and implementing custom behavior.
Variadic functions must have at least one fixed parameter before the ellipsis (...). This allows the function to know where variadic arguments begin. Type checking is NOT enforced for variadic arguments.
The restrict keyword informs the compiler that the pointer is the sole means of accessing the data it points to, allowing for optimization. It's a hint for compiler optimization.
The C standard does not specify the order of evaluation of function arguments. The order is implementation-dependent and can vary between compilers.
Variadic functions (using ...) don't validate argument count. Calling with fewer arguments leads to undefined behavior as the function reads undefined values from stack.
int x = 10;
int* getAddress() { return &x; }
main() { int *ptr = getAddress(); printf("%d", *ptr); }
Since x is static (global scope), returning its address is safe and the pointer remains valid. The output is 10. If x were local, it would be undefined behavior.
The restrict keyword (C99) is a promise to the compiler that the pointer is the only way to access that memory during its lifetime, allowing aggressive optimizations.
Passing large structures by pointer is more efficient as only address (typically 4-8 bytes) is copied, not entire structure.