Static Variable Syntax: we use static keyword before declaration.
One use of Static Variables is in functions,
when we want to store a value within a function, and not want to destroy it even when the function is ended...
eg: we want to know how many times a function is called.
Code:
void myfunction()
{
static int count=0;
/* Body of Our Function
*/
count++;
}
Static variable count is created when first time we call this function. And is not destroyed until execution of whole program is completed.
when ever we call this function, count is incremented by 1.
So We may easily calculate the number of times a function is executed