Vidyalelo
R Programming · all questions

Control Structures in R Programming
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

207

Questions

1/11

Page

Pick an option on a question to see the right answer and solution.

Which control structure in R is used to execute a block of code repeatedly until a condition is met?

Select an option to see the answer and solution.

In R, what is the purpose of the if-else statement?

Select an option to see the answer and solution.

How is the switch() function used in R?

Select an option to see the answer and solution.

In R, what is the syntax for the for loop?

Select an option to see the answer and solution.

What is the purpose of the break statement in a loop in R?

Select an option to see the answer and solution.

How is a while loop different from a for loop in R?

Select an option to see the answer and solution.

What does the next statement do in R?

Select an option to see the answer and solution.

In R, what is the purpose of the repeat loop?

Select an option to see the answer and solution.

What is the result of the expression 5 %% 2 in R?

Select an option to see the answer and solution.

In R, what is the role of the ifelse() function?

Select an option to see the answer and solution.

How is a do-while loop implemented in R?

Select an option to see the answer and solution.

In R, what does the if (condition) { code_block } else { code_block } statement do?

Select an option to see the answer and solution.

How is the repeat loop terminated in R?

Select an option to see the answer and solution.

What is the purpose of the which() function in R?

Select an option to see the answer and solution.

How do you create a vector containing the first 5 positive even numbers in R using a loop?

Select an option to see the answer and solution.

What is the output of the following R code: for (i in 1:5) { if (i %% 2 == 0) { print(i) } }

Select an option to see the answer and solution.

In R, what is the purpose of the repeat loop combined with break?

Select an option to see the answer and solution.

How is the switch() function different from if-else in R?

Select an option to see the answer and solution.

What is the role of the next statement in a loop in R?

Select an option to see the answer and solution.

In R, what does the repeat loop combined with next do?

Select an option to see the answer and solution.