Array Initialization in C

For Complete YouTube Video: Click Here

In this class, we will understand Array Initialization in C.

We have covered how to declare an array in our previous class, but we haven’t initialized an array.

Array Initialization

The image below shows how to initialize an array.

Array Initialization in C
Array Initialization in C

In the array initialization, we have to use curly braces to provide the elements of an array.

The image below is an array after initialization.

Array Initialization in C
Array with values

Different ways of Array Initialization

There are different ways of an array initialization.

The below discussion is about different ways of array initialization.

In the above image, only a few values have been initialized.

Array Initialization in C with less values
Array Initialization in C with less values

In this kind of initialization, the remaining values are filled with zeros, as shown below.

Array Initialization in C with less values visualization
Array with less values visualization

The image below is a way of initialization where the values of the array are filled with zeros.

Array Initialization in C with all values assigned to 0
Array with all values assigned to 0

The values of the array after initialization is as shown below.

Array Initialization in C with all values assigned to 0 visualization
Array with all values assigned to 0 visualization