+ 1

How is the output 16?

I was doing a challenge and I came across this question with code similar to this but written in C#. How is the output 16 can someone explain that to me? https://code.sololearn.com/c10Jz7oEbTz9/?ref=app

2nd Jan 2019, 2:11 PM
Pirate_Programmer
Pirate_Programmer - avatar
2 Réponses
+ 2
You start with j=3 In the for loop, you go from i=5 to i=8, where j is increased in each of these four steps i j 5 4 6 5 7 6 8 7 9 loop condition not met So after the loop, i=9 and j=7 Therefore i+j gives you the result 16
2nd Jan 2019, 2:16 PM
Matthias
Matthias - avatar
+ 2
Ohhhhh ok, thx
2nd Jan 2019, 2:26 PM
Pirate_Programmer
Pirate_Programmer - avatar