3.
Which of the following R code snippet stops loop after 20 iterations?

for(i in 1:100) {
      print(i)
              if(i > 20) {
               break 
       } 
}

for(i in 1:100) {
      print(i)
              if(i > 19) {
               break 
       } 
}

for(i in 1:100) {
      print(i)
              if(i < 20) {
               break 
       } 
}

for(i in 2:100) {
      print("i")
              if(i > 150) {
               break 
       } 
}

9.
Which of the following R code generate a sequence of integers from 1 to 10?

> for(i in 1:9) {
    + print(i)
+ }
[1]

> for(i in 0:9) {
    + print(i)
+ }
[1]

> for(i in 1:10) {
    + print(i)
+ }
[1]

> for(i in 2:50) {
    + print("i")
+ }
[1]

Read More Section(Control Structures in R Programming)

Each Section contains maximum 100 MCQs question on Control Structures in R Programming. To get more questions visit other sections.