Which loop should be used when the number of iterations is not known beforehand?

Which loop should be used when the number of iterations is not known beforehand?

a) while loop
b) for loop
c) repeat loop
d) do-while loop

Answer:

a) while loop

Explanation:

The while loop is used when the number of iterations is not known beforehand. It continues until the condition becomes false.

Reference:

R Programming – Loops MCQ Questions and Answers

Scroll to Top