+ 1
Why the answer is -1?
#include <stdio.h> #define square(x) x*x int main() { int i=square(4-1); printf("%d",i); return 0; } https://code.sololearn.com/cwpxqN047TC7/?ref=app
5 odpowiedzi
+ 10
HamidReza , evaluate it => 4-1*4-1=> 4-4-1=> - 1.
+ 2
thnx.
+ 2
#include<stdio.h>
#define square(x) x*
int main()
{
int i=square(4-1);
/* It basically work as:
i=4-1*4-1
Multiplication solves first so,the above statement becomes
i=4-4-1
i=-1 */
printf("%d",i);
return 0;
}
+ 1
Thank you TheWh¡teCat 🇧🇬
https://code.sololearn.com/cerU8AFJDS11
+ 1
Add parenthesis for your code to work
#define square(x) (x)*(x)