Page 23 - PROGRAMMING IN C_Neat
P. 23
There are four storage classes:
1. Automatic Variables:
These variables are declared inside a function.
General Form:
auto datatype variablename;
Example:
main()
{
auto int a;
_ _ _
_ _ _
_ _ _
}
2. External Variables:
These variables are declared outside all the functions.
They are common to all the functions.
Example:
int a;
main()
{
_ _ _
_ _ _
_ _ _
}
void xyz()
{
_ _ _
_ _ _
_ _ _
}
3. Static Variables:
These variables retain their values until the end of the program.
General Form:
static datatype variablename;
Example:
static int a;
4. Register Variables:
These variables are stored in the CPU registers.
General Form:
register datatype variablename;
Example:
register int a;
_______________________________________________________________________________________