These 2 recursive funtions won't work with me.

This is a discussion on These 2 recursive funtions won't work with me. within the C Programming forums, part of the General Programming Boards category; these are 2 programs that I need to depend on recursive functions when writing them but they give me wrong ...

1. These 2 recursive funtions won't work with me.

these are 2 programs that I need to depend on recursive functions when writing them but they give me wrong answers.Plz help

Code:
```This program is for calculating the factorial of a number the user inputs:

#include<stdio.h>
#include<math.h>
int main(void)
{
int n;
int factorial(int n);
int y;
y=factorial(n);
printf("enter the number you wish to calculate its factorial:");
scanf("%d" ,&n);
}
int factorial(int n){
if(n==0)
return (1);
else
return (n*factorial(n-1));
}```
Code:
```This program is for calculating numbers raised to integer powers.

#include<stdio.h>
#include<math.h>
int main(void)
{
int x,y;
int power(int x, int y);
int d;
d=power(x,y);
printf("enter the number of the base then the number of the power:");
scanf("%d%d" ,&x, &y);
}
int power(x,y){
if(y==0)
return (1);
else
return (x*power(x,(y-1)));
}```

2. In your First Code just place

Code:
`y=factorial(n);`
after
Code:
`scanf("%d" ,&n);`
line
You are doing the same mistake in the second program

just place
Code:
`d=power(x,y);`
after scanf statement

3. thanks it worked