Which loop is used when the number of iterations is known?
-
A
while
-
B
for
Correct answer
-
C
do-while
-
D
if
10 views
Explanation
A for loop is ideal when you know how many times to repeat. A while loop is better when the condition is open-ended.
Reference
Asked in: Matric,FBISE
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ