Bird
0
0

What will be the output of the following Swift code?

medium📝 Predict Output Q13 of 15
Swift - Operators and Expressions
What will be the output of the following Swift code?
let x = 10
let y = 20
print(x > y)
Atrue
B10
C20
Dfalse
Step-by-Step Solution
Solution:
  1. Step 1: Understand the comparison

    The code compares if x (10) is greater than y (20).
  2. Step 2: Evaluate the comparison

    Since 10 is not greater than 20, the expression x > y is false.
  3. Final Answer:

    false -> Option D
  4. Quick Check:

    10 > 20 = false [OK]
Quick Trick: Compare values carefully, > means strictly greater [OK]
Common Mistakes:
  • Assuming 10 > 20 is true
  • Confusing > with <
  • Printing variable values instead of boolean

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes