0

How?

I had this question in a challenge on sololearn and the somehow the answer is that x = 1. How? The left side of the statement is false so it means that x=1 and then they add 1 to x so x = 2. Right? int x = !(1 > 0) ? 0:1; x = x++;

7th Jul 2020, 11:19 AM
Yahel
Yahel - avatar
3 ответов
+ 8
Here The value of x is 1 and then the value is post incremented . So x = 1 x = x++; x will be one only Note : inpost incremented method the value of the variable is initialised first followed by the increment of the value
7th Jul 2020, 11:24 AM
Nilesh
Nilesh - avatar
+ 2
x is incremented to 2 later, in x=x++ ,here x is 1
7th Jul 2020, 11:24 AM
Abhay
Abhay - avatar
0
Thanks!
7th Jul 2020, 11:34 AM
Yahel
Yahel - avatar