0
i=5; what is the output of i=(++i/i++);
explain
3 Answers
0
Answer: i=1
The code in words verses the code:
1) insert 5 into i --- i=5
2) insert into i the result of --- i=
3) prefix i --- ++i
4) which means it increases the value of i by one and then uses it.
so now i=6 and the code is:
i=(6/i++)
5) postfix i --- i++
6) which means it first uses i in the code and then increases it by 1 (before it starts to run on the code again).
so now the code is: i=(6/6)
and i=7
7) insert into i (6/6), which equals 1.
So i=1.
0
but in my compiler its output is 2
0
I wrote the code here: https://code.sololearn.com/cT2frmvJ36FM/?ref=app