this function can be used instead of global variable.
if i==0 the function return 0 && if i ==1 the function return 1 && else the function return the value stored in the static variable.
Static variables have a property of preserving their value even after they are out of their scope! Hence, static variables preserve their previous value in their previous scope and are not initialized again in the new scope. Syntax :
static data_type var_name = var_value;