Bird
0
0

What will be the output of the following Ruby code?

medium📝 Predict Output Q13 of 15
Ruby - Operators and Expressions
What will be the output of the following Ruby code?
a = 5
b = 10
puts a < b
Atrue
Bfalse
C5
D10
Step-by-Step Solution
Solution:
  1. Step 1: Understand the comparison

    The code compares if a (5) is less than b (10).
  2. Step 2: Evaluate the comparison

    Since 5 is less than 10, the expression a < b is true.
  3. Final Answer:

    true -> Option A
  4. Quick Check:

    5 < 10 = true [OK]
Quick Trick: Less than is <, returns true or false [OK]
Common Mistakes:
  • Confusing output with variable values
  • Expecting numeric output instead of boolean
  • Mixing up < and > operators

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes