193k views
0 votes
Consider the following code snippet. Is count < 5 always true, always false, or sometimes true/sometimes false at point 2?

int count= 0;
while (count< 5)
System. out. printIn("CodeHS Rocks!")
count++ ;
// point 2
}

a. count 5 is always true at point 2
b. count 5 always false at point 2
c. count 5 is sometimes true/ sometimes false at point 2

User Mohonish
by
6.6k points

1 Answer

5 votes

Answer:

c. count 5 is sometimes true/ sometimes false at point 2

Step-by-step explanation:

The while-loop statement is a conditional looping statement in programming that executes a block of code if a condition is met.

In the program, the value of the count variable is first initialized to zero but the while-loop would continuously increment the count variable by one if the count variable is less than five, which means that the while-loop stops and the code block is not executed at count equal to five.

User Konstantin Konopko
by
5.6k points