34.
What will be the output of the following R code?
> printmessage2 <- function(x) {
+     if(is.na(x))
+             print("x is a missing value!")
+     else if(x > 0)
+             print("x is greater than zero")
+     else
+             print("x is less than or equal to zero")
+     invisible(x)
+ }
> printmessage2(NA)

36.
Which of the following is valid syntax for if else statement in R?

if(<condition>) {
          ## do something
}
else {
          ## do something else
}

if(<condition>) {
          ## do something
}
elseif {
          ## do something else
}

if(<condition>) {
          ## do something
}
else if {
          ## do something else
}

if(<condition>) {
          ##& do something
}
else {
          ##@ do something else
}

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.