Skip to main content

Control Structures In R Programming — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Control Structures In R Programming — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

R Commander is used to . . . . . . . . in R.

Question 2 of 40
★ FPSC ★ PPSC

R has . . . . . . . . basic indexing operators.

Question 3 of 40
★ FPSC ★ PPSC

Which of the following code skips the first 20 iterations?

Question 4 of 40
★ FPSC ★ PPSC

If the function in a console is.matrix(X) returns true then X can be considered as a . . . . . . . .

Question 5 of 40
★ FPSC ★ PPSC

How is a Data object represented internally in R language?

Question 6 of 40
★ FPSC ★ PPSC

. . . . . . . . function can be used to add datasets in R provided with the columns in the datasets should be the same.

Question 7 of 40
★ FPSC ★ PPSC

If the programmers want the output to be a data frame or a vector, then . . . . . . . . function is used.

Question 8 of 40
★ FPSC ★ PPSC

. . . . . . . . loop over a list and evaluate a function on each element.

Question 9 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > printmessage <- function(x) { + if(x > 0) + print("x is greater than zero") + else + print("x is less than or equal to zero") + invisible(x) + } > printmessage(NA)

Question 10 of 40
★ FPSC ★ PPSC

What is the command used to store R objects in a file?

Question 11 of 40
★ FPSC ★ PPSC

Which of the following R code will print "Neither"?

Question 12 of 40
★ FPSC ★ PPSC

. . . . . . . . function generates "n" normal random numbers based on the mean and standard deviation arguments passed to the function.

Question 13 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > x <- list(a = matrix(1:4, 2, 2), b = matrix(1:6, 3, 2)) > lapply(x, function(elt) { elt[,1] })

Question 14 of 40
★ FPSC ★ PPSC

. . . . . . . . is the easiest method for reshaping the data before analysis.

Question 15 of 40
★ FPSC ★ PPSC

. . . . . . . . returns TRUE then X can be termed as a matrix data object.

Question 16 of 40
★ FPSC ★ PPSC

. . . . . . . . package provides basic functionalities in R environment like arithmetic calculations, input/output.

Question 17 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > x <- 3 > switch(x, 2+2, mean(1:10), rnorm(5))

Question 18 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > x <- 1:4 > lapply(x, runif)

Question 19 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > x <- c("a", "b", "c", "d") > for(i in 1:4) { + ## Print out each element of 'x' + print(x[i]) + }

Question 20 of 40
★ FPSC ★ PPSC

. . . . . . . . function gives an error message if the desired package cannot be loaded.

Question 21 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > x <- list(a = 1:5, b = rnorm(10)) > lapply(x, mean)

Question 22 of 40
★ FPSC ★ PPSC

Which of the following R code syntax is syntactically valid?

Question 23 of 40
★ FPSC ★ PPSC

. . . . . . . . function takes various parameters like formula, data, subset, labels, etc.

Question 24 of 40
★ FPSC ★ PPSC

. . . . . . . . functions can be "built which contain all of the necessary data for evaluating the function.

Question 25 of 40
★ FPSC ★ PPSC

How many types of data structures does R language have?

Question 26 of 40
★ FPSC ★ PPSC

To get the current date, the . . . . . . . . function will return a Date object which can be converted to a different class if necessary.

Question 27 of 40
★ FPSC ★ PPSC

A matrix of scatterplots can be produced using . . . . . . . . function.

Question 28 of 40
★ FPSC ★ PPSC

. . . . . . . . suspends the execution of a function wherever it is called and puts the function in debug mode.

Question 29 of 40
★ FPSC ★ PPSC

Two vectors M and N are defined as M <- c(3, 2, 4) and N <- c(1, 2). What will be the output of vector Z that is defined as Z <- M*N.

Question 30 of 40
★ FPSC ★ PPSC

A programmer builds a . . . . . . . . to avoid repeating the same task or reduce complexity.

Question 31 of 40
★ FPSC ★ PPSC

Which of the following is valid body of split function?

Question 32 of 40
★ FPSC ★ PPSC

Which of the following is apply function in R?

Question 33 of 40
★ FPSC ★ PPSC

Which of the following R code will print "Hello, world!"?

Question 34 of 40
★ FPSC ★ PPSC

What will be the output of the following R code snippet? > f <- function(a, b) { + print(a) + print(b) + } > f(45)

Question 35 of 40
★ FPSC ★ PPSC

The syntax of the repeat loop is . . . . . . . .

Question 36 of 40
★ FPSC ★ PPSC

In the base graphics system, which function is used to add elements to a plot?

Question 37 of 40
★ FPSC ★ PPSC

Which of the following R code generate a uniform random number?

Question 38 of 40
★ FPSC ★ PPSC

Which function is used to select variables and observations from a given dataset?

Question 39 of 40
★ FPSC ★ PPSC

What will be the output of the following R code? > printmessage <- function(x) { + if(x > 0) + print("x is greater than zero") + else + print("x is less than or equal to zero") + invisible(x) + } > printmessage(1)

Question 40 of 40
★ FPSC ★ PPSC

. . . . . . . . is an indication that a fatal problem has occurred and execution of the function stops.

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →