156k views
3 votes
Which one of the following statements is a valid initialization of an array named somearray of ten elements? int[] somearray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int somearray[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; int[10] somearray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int somearray[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

User Jiminy
by
4.9k points

1 Answer

1 vote

Answer:

The answer to this question can be given as:

The valid statement for initialization of an array is the option first which is "int[] somearray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };".

Explanation:

Array is a collection of homogeneous elements. In the C programming language array can be divided into two parts that can be given as:

1-D (One-dimensional array)

2-D (two-dimensional array)

The valid statement for initialization of an array is int[] somearray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; and other option is not correct that can be described as:

In the option second, there we initialize 11 elements in array but the size of the array is fixed that is 10.

In option three, it is not a correct syntax for declaring an array.

In the option fourth, we initialize this type array during declaration.

User John Evans
by
4.8k points