Arrays Introduction

When we initialize an array as, int a[4] = {5};
Shouldn’t the first value be 5 and the rest 3 be garbage values?
But in the video, he has said that the first element is 5 and the rest are 0. Why?

Hey @Sharleen-Clement-3051084341644767
This is how this initialization works .
whenever we use {a,b,c,…} to initialize, then the mentioned nos are assigned in order and for the rest everything is set to 0.

1 Like