Uninitialized variable
In computing, an uninitialized variable is a variable that is declared but is not set to a definite value before it is used. As such it is a programming error and a common source of bug in software.
A common assumption made by novice programmers is that variables are set to a known value, such as zero, when they are declared. While this is true for many languages, it is not true for all of them, and so the potential for error is there. Languages such as C use stack space for variables, and the collection of variables allocated for a subroutine is known as a stack frame. While the computer will allow the approprate amount of space for the stack frame, it usually does so simply by adjusting the value of the stack pointer, and does not set the memory itself to any new state. Therefore whatever contents of that memory at the time will appear as initial values of the variables which occupy those addresses.
Here's a simple example in C:
void count( void ) {
int k, i
for(i=0; i<10; i++) k = k+1;
printf("%d", k);
}
What is the final value of k? The fact is, it is impossible to tell. The answer that it must be 10 assumes that it started at zero, which may or may not be true. Note that in the example, the variable i is initialized to zero by the first element of the for statement.
Most modern compilers will identify uninitialized variables and report it as a compile-time error.