Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

quiz 3 - loops consider the line of code below: n = 0 while (n < 6) dis…

Question

quiz 3 - loops
consider the line of code below:
n = 0
while (n < 6)
display(\woo\)
n = n + 2
how many times will \woo\ be displayed?
6
3
5
1

Explanation:

Step1: Initialize variable

$n = 0$

Step2: First loop check

Since $0<6$, "woo" is displayed, and $n=n + 2=2$

Step3: Second loop check

Since $2<6$, "woo" is displayed, and $n=n + 2=4$

Step4: Third loop check

Since $4<6$, "woo" is displayed, and $n=n + 2=6$

Step5: Fourth loop check

Since $6
ot<6$, loop ends.

Answer:

3