Why does this code = 27 instead of 21
7*7*7=21
Code:#include <stdio.h> #define x 5+2 main(){ int i; i=x*x*x; printf("%d",i); getchar(); getchar(); }
Why does this code = 27 instead of 21
7*7*7=21
Code:#include <stdio.h> #define x 5+2 main(){ int i; i=x*x*x; printf("%d",i); getchar(); getchar(); }
5 + 2 * 5 + 2 * 5 + 2.
This is what you said your code to do.
Read more here.
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
Oh and also, 7 * 7 * 7 is not 7*3, but 7³ = 343, that's why you need to wrap your value in parenthesis like this,
This was a good question you madeCode:#define x (5+2)
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
Haha, can't believe i didn't see the little math operations in that lol. Thank for the help
You are not the first one who did not, neither the last one
You are welcome
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson