Explain static variable in C

Explain static variable in C 


The value of static variables persists until the end of the program.
A variable can be declared static using the keyword static.
             static int y;
             static float x;
A static variable may be either an internal type or an external type depending on the place of declaration.
Internal static variables are those which are declared inside a function.
The scope of internal variable extend up to the end of the function in which they are defined. Therefore internal static variables are similar to auto variables except hat they remain in existence throughout the remainder of the program.
Therefore internal static variables can be used to retain values between function calls.

Labels: