Entrance Exams
Govt. Exams
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.
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.
A declaration tells the compiler about the function's signature (return type, name, parameters); a definition provides the actual implementation (function body).
The C standard does not specify the order of evaluation of function arguments. The order is implementation-dependent and can vary between compilers.
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.
In older C standards (C89/C90), if a function's return type is not specified, it defaults to int. However, modern C99 and later require explicit return type declaration.
C does not have a 'ref' keyword like C++. Pointers are used to achieve pass-by-reference semantics in C by passing the address of a variable.