QWhich of the following is a correct way to initialize an array?
Question Info
Choose the Best Option
Click any option to instantly check if you're correct.
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};❌ →ais 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};
Want to remember what you got wrong?
Create a free account in seconds to track your score, revisit mistakes and continue C++ language where you left off.
- Save your progress & streak
- Topic-wise quizzes & scores
- Bookmark tricky questions
- Printable MCQ sets
Nice — 3 questions done!
Don't lose this streak. Sign up free to save your score and pick up exactly where you stopped.
Share This Question
Challenge a friend or share with your study group.