What is the value of the res variable?
#define F(x) (2*x*x)

int main() {
    int a = 1, b = 2;
    int res = F(a + b);
    return 0;
It is equal to 6 since the given macro will be transformed into 2*а+b*a+b structure. In order to receive 2*(a+b)*(a+b) the macro should be defined as follows:
#define F(x) (2*(x)*(x))

Follow CodeGalaxy

Mobile Beta

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