Which of the following loops will run indefinitely unless manually stopped?

Which of the following loops will run indefinitely unless manually stopped?

a) while(TRUE)
b) for(i in 1:5)
c) while(i == 0)
d) for(i in 1:100)

Answer:

a) while(TRUE)

Explanation:

The while(TRUE) loop runs indefinitely since the condition always evaluates to true. It needs a break statement to stop it.

Reference:

R Programming – Loops MCQ Questions and Answers

Scroll to Top