A static variable is a local variable that retains its value across the function calls. Static variables are declared using the keyword “static”. Numeric variables which are static have the default value as zero.
The following function will print 1 2 3 if called thrice.
void f()
{
static int i;
++i;
printf(“%d “,i);
}
If a global variable is static, then its visibility is limited to the same source code.