C storage class determines
Storage class of variable Determines following things -
- Where the variable is stored
- Scope of Variable
- Default initial value
- Lifetime of variable
A. Where the variable is stored :
Storage Class determines the location of variable , Where it is declared. Variables declared with auto storage classes are declared inside main memory whereas variables declared with keyword register are stored inside the CPU Register.
B. Scope of Variable
Scope of Variable tells compile about the visibility of Variable in the block. Variable may have Block Scope , Local Scope and External Scope. Wiki has defined variable scope as -
C. Default Initial Value of the Variable
Whenever we declare a Variable in C, garbage value is assigned to the variable. Garbage Value may be considered as initial value of the variable. C Programming have different storage classes which has different initial values such as Global Variable have Initial Value as 0 while the Local auto variable have default initial garbage value.
D. Lifetime of variable
Lifetime of the = Time Of - Time of Variable variable Declaration Destruction
Suppose we have declared variable inside main function then variable will be destroyed only when the control comes out of the main .i.e end of the program.