[Solved] Output is not giving garbage value


Reading uninitialized variable follow below rules,

Static variable are by default initialized to zero means local static or file scope variable (global one).

Non-static variables which local to function are indeterminate. Reading them prior to assigning a value results in undefined behavior. compiler is free to do any thing. It can be zero, it can be the value that was in there, it can crash the program. you have absolutely no guarantees.

It will simply give you the last value that was stored in that position on the stack (or in that register if the variable happens to be stored in a register).

Also undefined might be different between different compilers.

solved Output is not giving garbage value