Variables Initialization


A variable can be considered as a box that can hold a single value. However, initially the content of a variable (or a box) is empty. Therefore, before one can use a variable, it must receive a value. Do not assume the compiler or computer will put some value, say 0, into a variable. There are at least three ways to put a value into a variable: The way of initializing a variable is very similar to the use of PARAMETER attribute. More precisely, do the following to initial a variable with the value of an expression: Initializing a variable is only done exactly once when the computer loads your program into memory for execution. That is, all initializations are done before the program starts its execution. The use of un-initialized variables may cause unexpected result.

Examples: