+ 5

Correct initialization of Array

Tell the correct initialization statements for array: options: a) int A[3] = {1,2,3}; b) int A[3] = {123}; c) int A[3] = "123"; 4) All

13th Nov 2017, 10:46 AM
Rushikesh Deshmukh
Rushikesh Deshmukh - avatar
2 Answers
+ 1
Challenge question? Most probably (a) is the right answer, the numbers match the array definition, (b) seems fine, but the second and third element is left undefined, (c) is definitely wrong, array A is of type int, assigning string into it will trigger error, (d) you figure it out :) Hth, cmiiw
13th Nov 2017, 10:52 AM
Ipang
+ 2
A is the correct answer. B lacks commas, C lacks curlies. Most definately not 4.
3rd May 2018, 2:28 PM
Michelle
Michelle - avatar