285 views
1 votes
1 votes

Choose the right option.

#define X 8
int main(void)
{
    	cout<<++X;
        return 0;
}

A) 8                              B) 9

C) Garbage Value       C) Compile Error

1 Answer

Best answer
0 votes
0 votes

Answer is D.

Reason: Since X is a macro, the statement above will expand to “++8” after the preprocessor is run. This means “8” is the operand of the prefix increment operator. And, because 8 is an rvalue it can not be used as an argument to “++”. This, in turn, means that the code above will not compile.