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

• 11-04-2005
KidMan
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);     printf("the answer is:%d" ,y); } 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);     printf("the answer is:%d" ,d); } int power(x,y){     if(y==0)     return (1);     else     return (x*power(x,(y-1))); }```
• 11-04-2005
sunnypalsingh
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
• 11-04-2005
KidMan
thanks it worked