Let’s break your code down step-by-step so it’s crystal clear.
How it runs:
-
First loop
-
count = 1
count <= 3 → True
-
Print 1 * 2 = 2
-
Increase count → now count = 2
-
Second loop
-
count = 2
count <= 3 → True
-
Print 2 * 2 = 4
-
Increase count → now count = 3
-
Third loop
-
count = 3
count <= 3 → True
-
Print 3 * 2 = 6
-
Increase count → now count = 4
-
Fourth check
-
count = 4
count <= 3 → False → loop stops.
Final output:


0 Comments:
Post a Comment