168k views
0 votes
If a while loop is used as a count-controlled loop, what does it need?

1) to be a for loop
2) an iteration variable
3) built-in pseudocode
4) a nested if loop

User Timgavin
by
8.0k points

1 Answer

0 votes

Final answer:

A while loop requires an iteration variable to function as a count-controlled loop, where the variable is used to control the number of loop iterations.

Step-by-step explanation:

If a while loop is used as a count-controlled loop, it needs an iteration variable. This iteration variable is typically initialized before the loop begins and is incremented or decremented within the loop body. Unlike a for loop which has a built-in mechanism for iteration, a while loop requires the programmer to explicitly control the iteration process. A count-controlled loop should also have a clear condition that will eventually fail, allowing the loop to exit.

No built-in pseudocode or nested if loops are necessary for a while loop to function as a count-controlled loop.

User Droussel
by
7.7k points