0

i=5; what is the output of i=(++i/i++);

explain

26th Jan 2017, 6:15 PM
Prakash kumar Verma
Prakash kumar Verma - avatar
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.
26th Jan 2017, 7:20 PM
Nathan
Nathan - avatar
0
but in my compiler its output is 2
26th Jan 2017, 7:39 PM
Prakash kumar Verma
Prakash kumar Verma - avatar
26th Jan 2017, 8:54 PM
Nathan
Nathan - avatar