But before that let's do a recap
static data_type name = value;
static int harry = 7;
Even after using this variable it will still take some memory that's why global and static variables are not recommended.
#include <stdio.h>
int func1(int b)
{
static int myvar = 0;
printf("The value of myvar is %d\n", myvar);
myvar++;
return b + myvar;
}
int main()
{
int b = 100;
int val = func1(b); //here myvar is 0 as this runs first time
func1(b); //when function is called 2nd time the value of myvar become 1 even
though insisde the function
// it is initialized as 0 which mean that it forget the initalization
// printf("The value of func1 if %d",func1(b));
return 0;
}