Try this code if you want a global, but there is side effect :
int a;
int increment()
{
a = a + 1;
if (a == 100)
return 0;
else
return increment();
}
Prefer to use if you don't want side effect, and this solution DO NOT stack lot of function, because you call your function at the last statement.
int increment(int a)
{
if (a == 100)
return a;
else
return increment(a + 1);
}
For example this one create stack of function :
int increment(int a)
{
if (a == 100)
return a;
else
{
a = increment(a);
return (a + 1);
}
}