In C, what is the purpose of the 'static' keyword when used with a global variable?
ATo make it accessible only within the current file
BTo allocate it on the stack
CTo make it a constant
DTo prevent memory deallocation
Correct Answer:
A. To make it accessible only within the current file
EXPLANATION
When 'static' is used with a global variable, it restricts its scope to the current file (internal linkage), making it not accessible from other files.
Which of the following correctly declares a function pointer?
Aint *func;
Bint (*func)();
Cint func*();
Dint *func();
Correct Answer:
B. int (*func)();
EXPLANATION
Function pointers require parentheses around the pointer name: int (*func)(). Option D declares a function returning int pointer, not a function pointer.