bobtcowboy
12-05-2001, 10:58 PM
I'm a newbie C programmer here...
I'm trying to pass a value of 4 to a recursive function that gets the factorial value... for some reason, the value of "n" is reported as 0.0 when I get into the "nFact" function
the relevent bit from main.c
(void)printf(" The factorial of %d is %d\n",4, nFact(4));
in a file called nfact.c
int nFact(n)
float n;
{
if (n == 0)
return (1);
else
return (n * nFact(n-1));
}
Any help?
[ 05 December 2001: Message edited by: bobtcowboy ]
I'm trying to pass a value of 4 to a recursive function that gets the factorial value... for some reason, the value of "n" is reported as 0.0 when I get into the "nFact" function
the relevent bit from main.c
(void)printf(" The factorial of %d is %d\n",4, nFact(4));
in a file called nfact.c
int nFact(n)
float n;
{
if (n == 0)
return (1);
else
return (n * nFact(n-1));
}
Any help?
[ 05 December 2001: Message edited by: bobtcowboy ]