Bird
0
0

Which of the following is the correct way to write a logical AND operation in Swift?

easy📝 Syntax Q12 of 15
Swift - Data Types
Which of the following is the correct way to write a logical AND operation in Swift?
A<code>a && b</code>
B<code>a & b</code>
C<code>a and b</code>
D<code>a || b</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recall Swift logical AND syntax

    Swift uses && for logical AND, not a single ampersand or words.
  2. Step 2: Identify the correct syntax

    a && b uses &&, which is the correct logical AND operator.
  3. Final Answer:

    a && b -> Option A
  4. Quick Check:

    Logical AND in Swift is && [OK]
Quick Trick: Use double ampersand && for AND in Swift [OK]
Common Mistakes:
  • Using single & instead of &&
  • Writing 'and' as a word
  • Confusing AND with OR operator ||

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes