cant understand 3rd while loop question. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

cant understand 3rd while loop question.

1st Feb 2017, 5:57 PM
Muhammad Hamza
Muhammad Hamza - avatar
1 Answer
0
x=1 and 1<5, so we go into loop with x=2 (x++ executes ) 2%2=0, now x=4 4<5, so we go 2nd time into loop with x=5 (x++ executes ) 5%2=1, x=5 the while condition is not satisfied anymore, so loop brakes, x++ executes, x=6 loop was executed 2 times
10th Feb 2017, 2:30 PM
mads
mads - avatar