Below is the code, please pin point exactly where i am wrong. I have declared, defined the function, i don't know what is wrong.
#include<stdio.h>
int factorial(int b); /* Declaration */
int main()
{
int num;
printf("Enter number: ");
scanf("%d", &num);
printf("%d",factorial(num));
return 0;
}
int factorial(int b) /*Function definition*/
{
return b*factorial(b-1);
}
You need to end the recursion at some point:
int factorial(int b) /*Function definition*/
{
if (b == 0) return 1;
return b*factorial(b-1);
}