+ 1
x=1 x = ++x ++x; cout<<x<<endl;
The answer is 6.explain me how the answer is 6
2 ответов
+ 12
x = 1
x = ++x + ++x --> 1 = ++1 + ++1
When compiler sees first prefix increment operator
2 = 2 + ++2
When compiler sees the second prefix increment operator
3 = 3 + 3
Now compiler will sum both values and assign it to x
3 = 6 --> x = 6
+ 5
x = 1;
++x = 2;
++x = 3;
x = ++x + ++x;
x = 1 + 2 + 3;