What is right way to Initialize array?
A.int num[6] = { 2, 4, 12, 5, 45, 5 };
B.int n{} = { 2, 4, 12, 5, 45, 5 };
C.int n{6} = { 2, 4, 12 };
D.int n(6) = { 2, 4, 12, 5, 45, 5 };
Answers
Answered by
30
D. int n(6) = { 2,4,12,5,45,5};
Hope it helps u
Hope it helps u
Answered by
0
Correct option is option(a) int num[6] = { 2, 4, 12, 5, 45, 5 };
- The correct way to declare an array is that the first word is the data types of the array then the second word is the name of the array followed by the square brackets.
- In the square brackets, we have to specify the length of our array.
- In option(b), (c) and (d) square brackets are mission.So they are an incorrect way of initializing the array.
- Square brackets must be used to initialize an array as in option(a).
Similar questions
English,
7 months ago
English,
7 months ago
History,
7 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago