R Programming MCQ Questions And Answers - Loops

This section focuses on "Loops" in R Programming. These Multiple Choice Questions (MCQ) should be practiced to improve the R Programming skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.

1. Which loop executes a sequence of statements multiple times and abbreviates the code that manages the loop variable?

A. for
B. while
C. do-while
D. repeat

View Answer


2. Which of the following true about for loop?

A. Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.
B. it tests the condition at the end of the loop body.
C. Both A and B
D. None of the above

View Answer


3. Which statement simulates the behavior of R switch?

A. Next
B. Previous
C. break
D. goto

View Answer


4. In which statement terminates the loop statement and transfers execution to the statement immediately following the loop?

A. goto
B. switch
C. break
D. label

View Answer


5. Point out the wrong statement?

A. Multi-line expressions with curly braces are just not that easy to sort through when working on the command line
B. lappy() loops over a list, iterating over each element in that list
C. lapply() does not always returns a list
D. You cannot use lapply() to evaluate a function multiple times each with a different argument

View Answer


6. The mapply() function is a multivariate apply of sorts which applies a function in parallel over a set of arguments.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


7. Which of the following is valid body of split function?

A. function (x, f)
B. function (x, f, drop = FALSE, …)
C. function (x, drop = FALSE, …)
D. function (drop = FALSE, …)

View Answer


8. Which of the following character skip during execution?

v <- LETTERS[1:6]
for ( i in v) {
   
   if (i == ""D"") {
      next
   }
   print(i)
}

A. A
B. B
C. C
D. D

View Answer


9. What will be output for the following code?

v <- LETTERS[1]
for ( i in v) {
   print(v)
}

A. A
B. A B
C. A B C
D. A B C D

View Answer


10. What will be output for the following code?

v <- LETTERS[""A""]
for ( i in v) {
   print(v)
}

A. A
B. NAN
C. NA
D. Error

View Answer





Discussion



* You must be logged in to add comment.