Array in C++ Array in C++ MCQ Details
MCQ Practice Single Best Answer Topic: Array in C++

Q What is the output of the following code?

int a[3] = {10, 20, 30};
cout << a[1];

Question ID
#24497
Subchapter
Array in C++
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 10
  • B 20
  • C 30
  • D Garbage value
Correct Answer: B

Explanation

In C++, array indexing starts from 0.

int a[3] = {10, 20, 30};

Index-wise values:

  • a[0] = 10

  • a[1] = 20

  • a[2] = 30

The statement:

cout << a[1];

prints the value at index 1, which is 20.

 Correct Answer: B) 20

Share This Question

Share this MCQ with your friends or study group.