Doubt regarding initialization of an array

Why is it that other elements become zero when we are putting values for only the first few elements
like a[10]={0} or a[10]={1,2,3}.Shouldnt the other elements still contain garbage value?

It depends upon the storage location, if you declared any type of array without initializing anything as global or static then it has value zero.
If you declare it as local inside any function ie auto without initializing then it has garbage values.
And also if you declare any array with partially initializing as auto then the un-initializing array index will have value zero.

So that means if I partially initialise an array the rest of elements automatically turn 0,that is just the way it is and there is no other explanation right?

yes accroding to my observance i realised this fact only.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.