Declare and instantiate a one dimensional int array named evenNums with five elements. Use an initialiser list that
contains the first five even integers, starting with 11.
9.
the
Answers
Answered by
1
Explanation:
Data_type array_name[size_of_array];int num[5] = {1, 1, 1, 1, 1};
This will initialize the num array with value 1 at all index.
We may also ignore the size of the array:
int num[ ] = {1, 1, 1, 1, 1}
The array will be initialized to 0 in case we provide empty initializer list or just specify 0 in the initializer list.
int num[5] = { }; // num = [0, 0, 0, 0, 0]
int num[5] = { 0 }; // Below are some of the different ways in which all elements of an array can be initialized to the same value:
Initializer List: To initialize an array in C with the same value, the naive way is to provide an initializer list. We use this with small arrays.
Similar questions