Govt. Exams
Entrance Exams
A void function cannot return a value. Attempting to assign the return value of a void function to a variable will cause a compilation error in standard C compilers.
A declaration tells the compiler about the function's signature (return type, name, parameters); a definition provides the actual implementation (function body).
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.
A static function has internal linkage and is limited to the file in which it is defined. It cannot be accessed from other translation units.
A function prototype must have the return type first, followed by the function name and parameter list in parentheses. Option A is the correct syntax.
In void functions, return statement (without value) can be used to exit the function prematurely. It's optional at the end since function exits automatically.
int fact(int n) { if(n
fact(4) = 4*fact(3) = 4*3*fact(2) = 4*3*2*fact(1) = 4*3*2*1 = 24. This is a proper factorial implementation with correct base case.
int add(int a, int b) { return a + b; }
int main() { printf("%d", add(5, add(3, 2))); return 0; }
Inner add(3,2) returns 5, then add(5,5) returns 10. Functions can be nested in arguments as long as return type matches parameter type.
If a non-void function doesn't explicitly return a value, it returns whatever garbage value happens to be in the return register, leading to undefined behavior.
The correct syntax is return_type function_name(parameters). Option A follows proper C syntax with int as return type, func as name, and void indicating no parameters.