0
x=x+(3*2)
x=2 and result is 8,but they write 7
9 Answers
+ 2
#include <stdio.h>
int main() {
int x = 2;
x += 1; // x is now 3
x -= 1; // x is now 2
x *= 3; // x is now 6
x /= 2; // x is now 3
x %= 2; // x is now 1
x += 3 * 2; // x is now 7
printf("%d", x);
return 0;
}
+ 1
But x has changed value to 1.
+ 1
x was 2, but it changed value.
+ 1
...
x %= 2; // x=1
x += 3*2; // x+=6
1 + 6 == 7
0
Are you sure you didn't type x+(2+3)?
0
#include <stdio.h>
int main() {
int x = 2;
x += 1; // 3
x -= 1; // 2
x *= 3; // 6
x /= 2; // 3
x %= 2; // 1
x += 3 * 2; // 7
printf("%d", x);
return 0;
}
0
int x=2; it's condition
0
đThanks
0
If x = 2 then x=x+(2*3) = 8
2*3=6+2= 8