Ask 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

+5
Answers (1)
  1. 2 May, 12:31
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers