Bird
0
0

What will be the output of this Swift code?

medium📝 Predict Output Q4 of 15
Swift - Basics and Runtime

What will be the output of this Swift code?

print("Swift", terminator: "-")
print("Rocks")
ASwift Rocks
BSwift Rocks
CSwift-Rocks
DskcoR-tfiwS
Step-by-Step Solution
Solution:
  1. Step 1: Analyze first print statement

    It prints "Swift" and ends with a dash instead of newline because terminator is "-".
  2. Step 2: Analyze second print statement

    It prints "Rocks" and ends with default newline.
  3. Final Answer:

    Swift-Rocks -> Option C
  4. Quick Check:

    terminator changes line end = Swift-Rocks [OK]
Quick Trick: terminator changes line ending, default is newline [OK]
Common Mistakes:
  • Ignoring terminator effect
  • Expecting space instead of dash
  • Confusing newline with dash

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes