0
0
R Programmingprogramming~20 mins

Integer type in R Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Integer Type Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of integer division in R?
Consider the following R code:
x <- 7L
result <- x %/% 2
print(result)

What will be printed?
R Programming
x <- 7L
result <- x %/% 2
print(result)
A3
BError: non-integer division
C4
D3.5
Attempts:
2 left
💡 Hint
The operator %/% performs integer division, which discards the remainder.
Predict Output
intermediate
2:00remaining
What is the type of an integer literal in R?
What is the output of this code?
typeof(5L)
R Programming
typeof(5L)
A"double"
B"numeric"
C"integer"
D"logical"
Attempts:
2 left
💡 Hint
The suffix L forces the number to be an integer type.
🔧 Debug
advanced
2:00remaining
Why does this integer overflow happen?
Examine this R code:
large_int <- 2147483647L
result <- large_int + 1L
print(result)

What is the output and why?
R Programming
large_int <- 2147483647L
result <- large_int + 1L
print(result)
A-2147483648
B2147483648
CNA
DError: integer overflow
Attempts:
2 left
💡 Hint
R integers are 32-bit signed and wrap around on overflow.
🧠 Conceptual
advanced
2:00remaining
What happens when mixing integer and double in arithmetic?
What is the type of the result of this R expression?
typeof(5L + 2.0)
R Programming
typeof(5L + 2.0)
A"complex"
B"integer"
C"numeric"
D"double"
Attempts:
2 left
💡 Hint
R converts integers to doubles when mixed in arithmetic.
Predict Output
expert
2:00remaining
How many elements are in this integer vector after coercion?
What is the length of the vector created by this code?
vec <- c(1L, 2.5, 3L, TRUE, "4")
length(vec)
R Programming
vec <- c(1L, 2.5, 3L, TRUE, "4")
length(vec)
A4
B5
C3
DError: incompatible types
Attempts:
2 left
💡 Hint
All elements are coerced to a common type in c().