Bird
0
0

What will IRB display after running this code?

medium📝 Predict Output Q5 of 15
Ruby - Basics and Runtime
What will IRB display after running this code?
5 + 3 * 2
A16
B11
C13
D10
Step-by-Step Solution
Solution:
  1. Step 1: Apply Ruby operator precedence

    Multiplication (*) happens before addition (+).
  2. Step 2: Calculate 3 * 2 then add 5

    3 * 2 = 6, then 5 + 6 = 11.
  3. Final Answer:

    11 -> Option B
  4. Quick Check:

    5 + 3 * 2 = 11 [OK]
Quick Trick: Multiplication before addition in Ruby expressions [OK]
Common Mistakes:
MISTAKES
  • Adding before multiplying
  • Confusing operator precedence
  • Expecting string output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes