+5

Shouldn't there be a garbage value?

As far as I know if variable is not initialised then it should carry a garbage value then why in this question it is 0? Am I lacking some knowledge or there is something wrong with the question🤔🤔 https://www.sololearn.com/post/177828/?ref=app

11/18/2019 3:39:23 PM

Arsenic

6 Answers

New Answer

+4

Arsenic 0 can be a random value but to say that the answer of that question is 0 is not correct.

+5

If at least one element was given with an initialization, all the others should be set to zero. But since there's no initialization, afaik, it should be garbage values.

+5

Avinesh But in the question it says "int a[10];" without the initialization and in local scope ( probably ). In your case you're indeed correct, but in this case the answer is undefined, therefore 0 is incorrect.

+5

Here is the sample code It says that there should be a garbage value https://code.sololearn.com/cSjtWezU956C/?ref=app

+5

Taste globals, global static and local static variable are always initialized to their defaults if not initialized explicitly. Everything else must be initialized explicitly.

+5

I suggest that you report the question.