What is the output of the following C++ code? int a[3] = {5, 10, 15}; cout << a[0] + a[2];

Options

  • A. 15
  • B. 20
  • C. 25
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. 20

Detailed Explanation

Correct Answer: Option B — 20

Explanation: a[0] is 5 and a[2] is 15. Their sum is 5 + 15 = 20.