+ 2
Anyone tell me how the output become 17 ??
int result=0; for(int i=0; i<5;i++){ if(i==3){ result+=10; }else { result+=i; } }
3 ответов
+ 4
first loop result = 0+0= 0
second loop result = 0+1=1
third loop result = 1+2=3
fourth loop result = 3+10=13
fifth and final loop result = 13+4=17
+ 2
@TheLegend27 thnxxxx😊😊😊
+ 2
when (i=0,1,2,or 4) we use "result=result+I"
when (i=3) we use "result=result+10"
i=0 » result=0+0=0
i=1 » result=0+1=1
i=2 » result =1+2=3
(*) i=3 » result =3+10=13
i=4 » result =13+4=17
👍