Bird
0
0

How can you print a multi-line message using a single print statement in Swift?

hard📝 Application Q9 of 15
Swift - Basics and Runtime

How can you print a multi-line message using a single print statement in Swift?

ABoth A and C
BUse triple quotes for multi-line string literals
CUse \n inside a single string
DUse multiple print statements for each line
Step-by-Step Solution
Solution:
  1. Step 1: Recall multi-line string options

    Swift supports multi-line strings with triple quotes and escape sequences like \n.
  2. Step 2: Identify correct options

    Both triple quotes and \n inside strings allow multi-line output in one print.
  3. Final Answer:

    Use triple quotes for multi-line string literals -> Option B
  4. Quick Check:

    Multi-line strings = triple quotes or \n [OK]
Quick Trick: Use triple quotes or \n for multi-line print [OK]
Common Mistakes:
  • Thinking only multiple print statements work
  • Ignoring triple quotes feature

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes