Storage classes define the scope means within which portion variable is accessible and its lifetime means for how much time variable will remain in memory.
Storage classes available in C:
1. Automatic Storage class: Default storage class for the variables is known as Automatic storage class. Every variable declared is automatic variable by default. Auto variables are known as local or internal variables. These variables are destroyed automatically when execution of the program is over.
Syntax: auto data_type variable_name
2. Register storage class: Register storage class stores variables in CPU registers rather than in memory like all the other variables. Register variables can be accessed quickly by the CPU as they are stored in registers. If there is not enough space available in registers then these variables is stored in memory i.e. RAM.
Syntax: register data_type variable_name
3. External storage class: Variables of external storage class are global and are accessible to all the statements within the program. External variables are also known as global variables. Global variables are automatically initialized to zero. They are not related to a single function rather they are related to the whole program and are defined outside all functions.
Syntax: extern data_type variable_name
4. Static storage class: Static storage class defines those variables which are local to a function in which these variables are declared. These variables are also automatically initialized to 0. Static variables are stored in memory only once and are not removed from memory when execution of the function is over.
Syntax: static data_type variable_name