Hello I am a beginner in C programming language, recently i started learning arrays, I have studied that by default all values in an int ar
The C99 draft says:
If there are fewer initializers in a brace-enclosed list than there are elements or members of an aggregate, or fewer characters in a string literal used to initialize an array of known size than there are elements in the array, the remainder of the aggregate shall be initialized implicitly the same as objects that have static storage duration.
And static objects are initialized to zero.
So, there's a large difference between not having any initializer at all, that gives you the uninitialized contents of memory (what you call "garbage"), and having an initializer. If the initializer is there, but missing data, you get 0 by default.
This is very handy, since it makes it possible to 0-initialize a large array by doing just as you did.