What is the output of the following C++ code? int a[4] = {2, 4, 6, 8}; cout << a[2];

Options

  • A. 2
  • B. 4
  • C. 6
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. 6

Detailed Explanation

Correct Answer: Option C — 6

Explanation: Array indexing starts at zero. Therefore, a[0] is 2, a[1] is 4, and a[2] is 6.