+ 2

I am not getting this code

how is n11 https://code.sololearn.com/c2OIdCk1rwSH/?ref=app

3rd Oct 2017, 10:11 AM
Malhar Mujumdar
Malhar Mujumdar - avatar
9 Answers
+ 17
int m=2; int n=15; for (int i=1; i<5; i++) { m++; --n; // i = 1, m = 3, n = 14 // i = 2, m = 4, n = 13 // i = 3, m = 5, n = 12 // i = 4, m = 6, n = 11 }
3rd Oct 2017, 10:32 AM
Babak
Babak - avatar
+ 16
@Malhar, --n before print statement tells you that -- decreases the current value of n (which is 15) by one. So, your first outputted value is 14. Is it clear now?
3rd Oct 2017, 10:45 AM
Babak
Babak - avatar
+ 5
i is 1 2 3 4 following Which mean loop executed 4 times so n decreased by 1 4 times
3rd Oct 2017, 10:18 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
sorry I meant to say how no 15
3rd Oct 2017, 10:32 AM
Malhar Mujumdar
Malhar Mujumdar - avatar
0
n is 15
3rd Oct 2017, 10:32 AM
Malhar Mujumdar
Malhar Mujumdar - avatar
0
can anyone help please
3rd Oct 2017, 10:33 AM
Malhar Mujumdar
Malhar Mujumdar - avatar
0
n is 15
3rd Oct 2017, 10:33 AM
Malhar Mujumdar
Malhar Mujumdar - avatar
0
and the output is n=14 how is it 14
3rd Oct 2017, 10:34 AM
Malhar Mujumdar
Malhar Mujumdar - avatar
0
how is it possible
3rd Oct 2017, 10:34 AM
Malhar Mujumdar
Malhar Mujumdar - avatar