C program to find factorial of any number using recursion

C program to find factorial of any number using recursion

#include<stdio.h>
#include<conio.h>

void main()
{
int fac,n;
int factorial(int);
clrscr();

printf(“Enter any number:”);
scanf(“%d”,&n);

fac=factorial(n);
printf(“Factorial=%d”,fac);
getch();
}

int factorial(int x)
{
int f;
if(x==1||x==0)
return 1;
else
f=x*factorial(x-1);

return f;
}

3 thoughts on “C program to find factorial of any number using recursion”

  1. Can anybody tell me how to find factorial of any number using goto statement
    Please do not use ‘for,while’ or any other loop

Leave a Comment

Your email address will not be published. Required fields are marked *