Ask Question
29 October, 06:14

How many times will the following loop repeat?

i = 2; while i < = 16; i = i+2; end

A. 0 times

B. 2 times

C. 8 times

D. 16 times

+4
Answers (1)
  1. 29 October, 09:10
    0
    8 times

    Explanation:

    The while is execute again and again until the condition is TRUE.

    In the question:

    the value of i=2, when program enter the loop it check the condition when

    2 < = 16, condition TRUE. it update the value i = 4.

    Again the loop check condition, 4 < = 16, condition TRUE, i become 6 and so on ...

    4,6,8,10,12,14,16

    when i = 16 loop condition is also TRUE. 16 < = 16. So, it again run the loop and i become 18.

    then, the loop condition false and it exit the loop.

    so, i run until 18

    4,6,8,10,12,14,16,18

    Therefore, the answer is 8 times.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How many times will the following loop repeat? i = 2; while i < = 16; i = i+2; end A. 0 times B. 2 times C. 8 times D. 16 times ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers