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
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
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};❌ →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};
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic