What is the primary purpose of the 'volatile' keyword in C?
ATo prevent variable modification
BTo inform the compiler that a variable's value can change unexpectedly
CTo allocate memory dynamically
DTo declare function pointers
Correct Answer:
B. To inform the compiler that a variable's value can change unexpectedly
EXPLANATION
The 'volatile' keyword tells the compiler not to optimize accesses to a variable, as its value can change from external sources (hardware, signals, etc.).
Which of the following variable names is valid in C?
A2variable
Bvar-iable
C_variable123
Dvar iable
Correct Answer:
C. _variable123
EXPLANATION
Variable names in C must start with a letter or underscore, followed by alphanumeric characters or underscores. '_variable123' is valid, while '2variable' starts with digit, 'var-iable' has hyphen, and 'var iable' has space.