Quiz Question 1 of 5
Given the choice between using a nested for
loop and a nested while
loop to achieve the same output, under what circumstances is a for
loop more appropriate than a while
loop in the context of counting-based iteration, and why?
Choose the correct answer below:
-
A
When the number of iterations is known beforehand, a
for
loop is more efficient and easier to read. -
B
A
for
loop is always preferable because it minimizes the risk of infinite loops. -
C
A
while
loop is better suited for all cases involving nested loops due to its flexibility. -
D
When the loop depends on a complex condition, a
for
loop provides more control.