Entrance Exams
Govt. Exams
In C, arrays decay to pointers when passed to functions, meaning the address is passed. Any modifications through the pointer affect the original array. This is effectively pass-by-reference behavior for arrays.
All three approaches are valid for error handling in C. Functions typically return NULL for pointers, negative values for integers, or use predefined error codes to indicate failure states.
Inlining substitutes a function call with the actual function body at compile time, eliminating function call overhead. This is a compiler optimization for performance-critical code.
When an array is passed to a function, it decays to a pointer to its first element. This means modifications to array elements affect the original array outside the function.
If a function is declared but not defined, the compiler generates code to call it (compilation succeeds), but the linker fails to find the function definition, resulting in a linker error.
C provides multiple methods to return values: structs for encapsulation, pointers for indirect modification, and global variables (though not recommended). All three are technically valid approaches.
Function pointers enable polymorphism by allowing runtime selection of which function to call. They are crucial for implementing callbacks and dynamic function dispatch.
extern functions have external linkage and can be accessed from other translation units. It's the default linkage for functions declared outside a file.
When const is applied to a function parameter, it prevents modification of that parameter within the function body, making it immutable for the duration of the function.
A base case is essential in recursive functions to provide a stopping condition. Without it, the function will cause stack overflow. The base case ensures recursion terminates properly.