+ 8

[solved] 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

18th Nov 2019, 3:39 PM
Arsenic - avatar
4 Answers
+ 6
Here is the sample code It says that there should be a garbage value https://code.sololearn.com/c6pqJK7rdAf0/?ref=app
18th Nov 2019, 4:33 PM
Arsenic - avatar
+ 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.
18th Nov 2019, 4:16 PM
HonFu - avatar
+ 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.
18th Nov 2019, 4:17 PM
Dennis - avatar
+ 5
I suggest that you report the question.
20th Nov 2019, 8:44 AM
Sonic - avatar