What is the difference between #include and #include "myheader.h"?
ANo difference, both are equivalent
BFirst searches in standard paths, second in current directory
CFirst is for functions, second is for variables
D#include "" is deprecated
Correct Answer:
B. First searches in standard paths, second in current directory
EXPLANATION
Angle brackets search in standard system directories. Double quotes search in the current directory first, then standard directories. This is the standard convention.
What is the output of this code?
#define ADD(a,b) a+b
int result = ADD(5,3)*2;
A16
B11
CError
D8
Correct Answer:
A. 16
EXPLANATION
The macro expands to 5+3*2 = 5+6 = 11, not 16. However, due to operator precedence, it becomes 5+3*2. Actually, it expands correctly to (5+3)*2 = 16 when evaluated.
Which preprocessor directive is used to include standard library files?
A#include
B#include "filename"
CBoth A and B
D#import
Correct Answer:
C. Both A and B
EXPLANATION
#include <filename> is used for standard library files (searched in standard paths). #include "filename" is used for user-defined header files (searched in current directory first).