Machine-translated by Google. Questions are authored in English.
Top

Discussion

What is the syntax for accessing the element at index 7 of an array a?

  • A.a{7}
  • B.a(7)
  • C.a"7"
  • D.a[7]

Answer: D

Correct answer: a[7]

C uses square brackets for subscripting, so the element at index 7 is a[7]. Braces are for initialiser lists, parentheses would be read as a function call, and quotes make a string literal. Note that a[7] is the eighth element, since indexing starts at 0.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.