R Programming

Which of the following loops does not have a conditional check at the start?

Which of the following loops does not have a conditional check at the start? a) for loop b) while loop c) repeat loop d) do-while loop Answer: c) repeat loop Explanation: The repeat loop does not check any condition at the start; it runs indefinitely until a break statement is used. Reference: R Programming –

Which of the following loops does not have a conditional check at the start? Read More »

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

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

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

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

Scroll to Top