93.0k views
5 votes
As you are learning a client’s programming needs, you realize the program will require an iteration of tasks, yet there are exceptions when the task will not be performed. What type of loop should you use for the exceptions?

while loop

for loop

then loop

if loop

2 Answers

8 votes

Final answer:

A while loop is best for programming tasks that require iteration with exceptions, as it can be controlled using complex conditions.

Step-by-step explanation:

When addressing a client's programming needs that involve iteration with certain exceptions, the most suitable type of loop to use would be a while loop. A while loop is ideal because it can iterate over a block of code as long as a specified condition is true, and it allows for complex conditions and exceptions. For instance, it can run a task repeatedly until a particular condition is no longer met, which could represent the exception to not performing the task. In contrast, a for loop is generally used when the number of iterations is known beforehand. The options 'then loop' and 'if loop' are not standard loop constructs in programming.

User Deondra
by
4.1k points
8 votes
I think I would use the While loop
User Dmitry Ostashev
by
4.4k points