Why uninitialized variable print a strange negative value ?
int x;
cout << x << endl;
Why uninitialized variable print a strange negative value ?
int x;
cout << x << endl;
What you're doing (reading the value of an uninitialised variable) is undefined behaviour; anything can happen, from it appearing to work, to printing random values, to crashing, to buying pizza with your credit card.
An uninitialized variable is a variable that is declared but is not set to a definite known value before it is used. It will have some value, but not a predictable one.
When a variable is not initialized , it shows you "Garbage Value". What that mean is it can be any arbitrary number from anywhere, may be from another running application or random number from big pool of memory.