Why this macro gives output 144, instead of 121?
#include #define SQR(x) x*x int main() { int p=10; std::cout<
Because SQR(++p) expands to ++p*++p, which has undefined behavior in C/C++. In this case it incremented p twice before evaluating the multiplication. But you can't rely on that. It might be 121 (or even 42) with a different C/C++ compiler.