For given macro definition, what will be printed to the console?
#define Some_operation(x, y) ((x) + (y) - 1) / (y)

int main()
{
std::cout<< sizeof Some_operation(1,2);
}
Explanation
The precompiler will generate the following code: std::cout << sizeof ((1) + (2) - 1) / (2);
Since sizeof operator has a higher priority, it will be evaluated first, and then the result will be divided by 2, hence, the final result is 2.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes