SQ(a+2) == a+2*a+2 == a+(2*a)+2 you can fix this by protecting the macro and its args: #define SQ(x) ((x)*(x)) . The outer parentheses are not strictly needed here, I think, but are a good habit. For instance think about this:
#define DBL(x) (x)+(x)
printf("%d\n",3*DBL(2)) /*8 or 12?*/
Parameters are not evaluated in a defined order, so the compiler is free to evaluate in any of 6 possible ways. Fix it by passing independent variables to the function, by evaluating the parameters yourself into temporary locals, and passing the (now independent) temporaries to the function, or by being very careful. This last option will lead to bugs, when you get sleepy or in a hurry, so make it a habit not to do that.
SQ(a+2) == a+2*a+2 == a+(2*a)+2 you can fix this by protecting the macro and its args: #define SQ(x) ((x)*(x)) .
yes that i understood..
But my question is for SQ(a+2) >> a+(2*a)+2 ...that means when a=5 the answer is 17.
But in the code i've posted it's -SQ(a+2) ...and the answer's coming is 7..
i want to know the logic behind that...
I am working creating a fully encapsulated, homogeneous singly linked data structure. The Listing class and SinglyLinkedList class that are part of the whole application compile fine, but the problem ...