+ 2

How can be it is 17?

it should run one more time till it is less than 5 I mean for the 1st instance: i=0 0<5 i++ (ie i=1) it will by pass the i==3 condition and result=0+1 = 1 for the 2nd instance I=1 1<5 I++(ie i=2) it will by pass the i==3 condition and result=1+2 = 3 for the 3rd instance i=2 2<5 i++(ie i=3) it fullfils the condition i==3 so result will be 10+3 =13 for the 4th instance i=3 3<5 i++(ie i=4) it by will bypass the i==3 condition and result=13+4=17 Now i=4 4<5 so it should run one more time why does it stops ?

2nd Nov 2016, 12:24 PM
Krunal Dhameliya
Krunal Dhameliya - avatar
3 Answers
+ 2
i = {0,1,2,3,4} and 0 to 4 except 3 calculate in else and the result is 0, 1, 2, 4 and for 3 it equal to 0 + 10 so the answer is 17 (0+1+2+4+10).
3rd Nov 2016, 7:42 PM
ehsan shahbazi
ehsan shahbazi - avatar
+ 1
What is the code that you are talking about?
2nd Nov 2016, 1:47 PM
nedas
nedas - avatar
0
jjb
3rd Nov 2016, 5:58 PM
Adam Saeed
Adam Saeed - avatar