Govt Exams
The static keyword restricts function scope to the file in which it is declared, preventing external linkage.
Both forms are valid. Functions decay to function pointers, so both &printf and printf assign the function address correctly.
The volatile keyword tells the compiler not to optimize away variable accesses, ensuring the variable is read from memory each time.
void func() { func(); } int main() { func(); }
This is infinite recursion with no base case, causing stack overflow as the function keeps calling itself.
A base case is essential in recursive functions to provide a termination condition, otherwise the function will recurse infinitely.
Function pointers enable runtime polymorphism by allowing selection of which function to call based on runtime conditions.
Functions can have multiple forward declarations but only one definition. This allows function prototypes in header files.
int func(int *p) { return *p; }
int main() { int x = 10; printf("%d", func(&x)); }
The function receives a pointer to x, dereferences it with *p, and returns the value 10.
While C99 guarantees support for at least 127 parameters, the actual limit is implementation-dependent and varies by compiler.
The function simply adds two integers and returns their sum, which is 5 + 3 = 8.