I can straight away store my calculated value in the uninitialized variable? in worst case scenario what will happen?(even though i dont find any compiling/logical error)

1 Answer 1


storing a value in an uninitialized variable is the same thing as initializing that variable.

a local variable, for example, does not have a default value when it is defined. any value may be in there. using that variable before ensuring that one of the values that your program expects is in there may cause your program to produce weird results or crash. for example:

int x;
int y = 10;
int z = x + y; // what do you think z is gonna have?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .