R

Ravina • 2.56K Points
Extraordinary

Q. What is the output of the following code?

Code:
let numbers = [1, 2, 3]
print(numbers[1])
  • (A) 1
  • (B) 2
  • (C) 3
  • (D) Index out of range
  • Correct Answer - Option(B)
  • Views: 1
  • Filed under category Swift (iOs)
  • Hashtags:

Explanation by: Ravina
Array indexing in Swift starts from 0. So, `numbers[1]` accesses the second element, which is 2.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.