Bird
0
0

What will be printed by this Swift code?

medium📝 Predict Output Q4 of 15
Swift - Control Flow
What will be printed by this Swift code?
let score = 75
if score >= 90 {
    print("Excellent")
} else if score >= 60 {
    print("Good")
} else {
    print("Try again")
}
AExcellent
BNo output
CGood
DTry again
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate the first condition

    score is 75, which is not >= 90, so skip first print.
  2. Step 2: Evaluate the else if condition

    75 is >= 60, so print "Good" and skip else block.
  3. Final Answer:

    Good -> Option C
  4. Quick Check:

    score 75 fits else if condition = Good [OK]
Quick Trick: Check conditions top to bottom; first true runs [OK]
Common Mistakes:
  • Printing 'Excellent' for 75
  • Printing 'Try again' incorrectly
  • Assuming multiple prints happen

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes