0

int result =0; for (int i = 0;i<5;i++){ if(i==3){ result+=10; }else{ result+=i; } } system.out.println(result);

Any body help me for this question?

12th Apr 2018, 7:47 PM
Ahsan Designer
Ahsan Designer - avatar
2 odpowiedzi
+ 15
first loop i=0 is !=3 will run in else statement 0+=0=0 result=0 second loop i=1 !=3 will run in else statement 0+=1 result=1 3rd loop i=2 !=3 will run in else statement 1+=2 result=3 4th loop i=3 i==3 true so will run in if statement 3 +=10 result =13 last loop i=4 !=3 so will run in else statement 13+4=17 result=17
12th Apr 2018, 9:44 PM
)_)
)_) - avatar
+ 1
result changes are: 0, 1, 3, 13, 17 so 17 will print
12th Apr 2018, 8:02 PM
🇮🇷 M N