Which of the following loops is considered infinite?

Which of the following loops is considered infinite?

a) for(i in 1:5)
b) repeat { print(1) }
c) while(i <= 5)
d) None of the above

Answer:

b) repeat { print(1) }

Explanation:

The repeat loop will continue indefinitely unless a break statement is encountered, making it an infinite loop.

Reference:

R Programming – Loops MCQ Questions and Answers

Scroll to Top