Default value of variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Default value of variable

Declared an int variable with no value and another with value '2'.. why does I get 10 as output..explain me

5th Nov 2018, 11:24 AM
Nithin
1 Answer
+ 2
If you just declare them, they are not necessarily empty: At that place in memory there might be still sitting something. That's why you should initialize - to be sure what you get.
5th Nov 2018, 11:29 AM
HonFu
HonFu - avatar