If x = 5; how comes when you do ++x = 5. | Sololearn: Learn to code for FREE!
+ 3

If x = 5; how comes when you do ++x = 5.

and not 6?

17th Apr 2017, 2:02 PM
RSPS Hobo
RSPS Hobo - avatar
6 odpowiedzi
+ 10
x = 5; // 5 is assigned to x ++x = 5; // x is incremented by one, and then 5 is assigned to x // result? x is still 5, because the incrementing comes before the assigning.
17th Apr 2017, 2:04 PM
Hatsy Rei
Hatsy Rei - avatar
+ 9
If x = 5, x++ will be 5 but ++x will be 6.
17th Apr 2017, 2:04 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 3
Good question, good answer.
17th Apr 2017, 2:27 PM
Yasar Curci
Yasar Curci - avatar
+ 3
thanks guys
17th Apr 2017, 2:28 PM
RSPS Hobo
RSPS Hobo - avatar
0
hello
18th Apr 2017, 4:40 AM
Шамиль Сарваров
Шамиль Сарваров - avatar
0
++x = 6
18th Apr 2017, 6:27 AM
anurag bhati
anurag bhati - avatar