#include<stdio.h>
int fun(int i)
{
if ( i%2 ) return (i++);
else return fun(fun( i - 1 ));
}
int main()
{
printf(" %d ", fun(200));
return 0;
}
Why is this programme not getting into infinte loop
#include<stdio.h>
int fun(int i)
{
if ( i%2 ) return (i++);
else return fun(fun( i - 1 ));
}
int main()
{
printf(" %d ", fun(200));
return 0;
}
Why is this programme not getting into infinte loop
#include<stdio.h>
int fun(int i)
{
if ( i%2 ) return (++i);
else return fun(fun( i - 1 ));
}
int main()
{
printf(" %d ", fun(200));
return 0;
}
this will get stuck see, when u are returning i++ i gets incremented after returning so the scope of new i is until that function but since it has returned that means it’s scope is over calling it by reference or keeping it static will also have the same effect