Q4 Write a C program to show the storage, default initial value, scope and life of a static storage class variable.
Program: 142
Write a C program to show the storage, default initial value, scope and life of static storage class variables.
Variable Storage Class tells us:
- Storage (location)
- Default Initial Value of the variable
- Scope of the variable
- Life of the variable
1. Storage: Where the variable would be stored.
2. Default Initial Value: What will be the initial value of the variable, if initial value is not specifically assigned. (i.e. the default initial value)
3. Scope: What is the scope of the variable: i.e. in which functions the value of the variable would be available.
4. Life: What is the life of the variable: i.e. how long would the variable exist.
Static Storage Class:
Same as Automatic Storage Class but value remains stored in memory when the function no longer active and it default initial value is zero (0).
Storage : Memory
Default Initial Values : Zero
Scope : Local to the block remains within the block in which the variable defined.
Life : Value of the variable persists between different function calls.
Output:
1 2 3