Okay, think about this:
Code:
#include "stdio.h"
#define max(a,b) (a)>(b)? a : b
int g=0;
int testfunc (int X, int Y) {
return max(X,Y);
}
int ab(int n, int a)
{
if (n==0) return 5;
printf("a=.....%d\n",a);
printf("g=.....%d\n",g);
printf("-------------\n");
g=-50;
a-=1;
g=testfunc(g,ab(n-1,a));
printf("a(%d)==========%d\n",n,a);
return g;
}
void main(void)
{
ab(2,10);
}
Produces the expected:
a=.....10
g=.....0
-------------
a=.....9
g=.....-50
-------------
a(1)==========8
a(2)==========9
ps. look for stuff about the Fibonacci set, that is the essential form of recursion I think