I am learning C and i come up with this example
#include <stdio.h>
int MyAdd(int);
main ()
{
int i;
int c = 0;
c = MyAdd(5);
printf("%d\n", c);
}
int MyAdd(int a)
{
if(a > 0)
return a + MyAdd(--a);
else
return 0;
}
I run this by my self and i calculate 15. (5 +4+3+2+1) but when i run it, i get 10... why??? At the 1st time, dont we get 5+ (do the func again) and etc..?