Bird
0
0

What is the output of this Kotlin code?

medium📝 Predict Output Q4 of 15
Kotlin - Operators and Expressions
What is the output of this Kotlin code?
val x = 15
val y = 4
println(x % y)
A0
B4
C11
D3
Step-by-Step Solution
Solution:
  1. Step 1: Understand the modulus operator

    The % operator gives the remainder of division.
  2. Step 2: Calculate remainder of 15 divided by 4

    15 divided by 4 is 3 times 4 = 12, remainder 3.
  3. Final Answer:

    3 -> Option D
  4. Quick Check:

    Modulus operator result = 3 [OK]
Quick Trick: Use % to find remainder after division [OK]
Common Mistakes:
MISTAKES
  • Confusing % with division
  • Calculating quotient instead of remainder
  • Using wrong divisor

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes