Govt. Exams
Entrance Exams
Function prototypes inform the compiler about function name, return type, and parameters before the actual definition, enabling proper type checking during compilation.
Declaration (prototype) informs compiler about function signature; definition provides the actual implementation body.
Call by value passes a copy of the variable. Changes inside the function don't affect the original variable. Option B demonstrates this principle.
C requires function declaration before use (forward declaration or definition). Calling without prior declaration causes compilation error in modern C standards.
The void keyword is used as return type for functions that do not return any value.
The static keyword restricts function scope to the file in which it is declared, preventing external linkage.
A base case is essential in recursive functions to provide a termination condition, otherwise the function will recurse infinitely.
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.
The function simply adds two integers and returns their sum, which is 5 + 3 = 8.
Pre-increment (++x) increments and returns the new value, while post-increment (x++) increments but returns the old value.