Array in C++ Array in C++ Question #24496
MCQ Single Best Answer Moderate

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

ID: #24496 Array in C++ 26 views
Question Info
#24496Q ID
ModerateDifficulty
Array in C++Topic

Choose the Best Option

Click any option to instantly check if you're 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: Option 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

Challenge a friend or share with your study group.