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

Q Which of the following is a correct way to initialize an array?

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

Choose Your Answer

Click an option to check whether your answer is correct.

  • A int a = {1,2,3};
  • B int a[3] = 1,2,3;
  • C int a[3] = {1,2,3};
  • D int a(3) = {1,2,3};
Correct Answer: C

Explanation

In C++, an array must be declared with a size and initialized using curly braces { }.

int a[3] = {1, 2, 3};

This statement:

  • Declares an array of 3 integers

  • Correctly initializes all elements

Why other options are wrong

  • A) int a = {1,2,3}; ❌ → a is not an array

  • B) int a[3] = 1,2,3; ❌ → Missing { }

  • D) int a(3) = {1,2,3}; ❌ → Invalid array syntax

Correct Answer: C) int a[3] = {1,2,3};

Share This Question

Share this MCQ with your friends or study group.