134k views
3 votes
. What is the final value of “y” after this for loop is finished? for (y = 3; y<=14; y+=5)

1 Answer

6 votes

Answer:

18

Step-by-step explanation:

In First iteration y = 3 and condition is y<=14 i.e. 3<=14 means true and continue the loop and increment the value of y by 5, means y will become 8

In Second iteration y = 8 and condition is y<=14 i.e. 8<=14 means true and continue the loop and increment the value of y by 5, means y will become 13

In Third iteration y = 13 and condition is y<=14 i.e. 13<=14 means true and continue the loop and increment the value of y by 5, means y will become 18

In Fourth iteration y = 18 and condition is y<=14 i.e. 18<=14 means false and exit from the loop

So the value of y will be 18 after the loop

User Solomon
by
6.8k points