Computer Science, asked by suneetkaur, 4 months ago

How many times is the following loop executed?
FOR N = 8 TO 3 STEP 2
PRINT N
NEXT N​

Answers

Answered by pea4518977
1

Answer:

When i = 0: It’s true because 0 < 4.

Hence, the loop executes 1 time.

The value of i then increments and is increased by one, hence:

Now, i = 1: This is again true because 1 < 4

Hence, loop executes 2 times.

The value of i then increments again and is increased again by 1.

So now, i = 2: This is true again because 2 < 4

Hence, the loop executes 3 times.

Now, the value of i increments,

and becomes 3.

Now, i = 3: This is true because 3 < 4

Hence, the loop executes for 4 times.

The value of i again is incremented and it changes into 4.

But when i = 4, 4 < 4 is not true.

Thus, the construct comes out of the loop.

Hence, the loop executes 4 times.

THANKS!

Explanation:

Similar questions