C Program to calculate Factorial of a number by Recursion
#include<stdio.h>
#include<conio.h>
int f1=1;
int factorial(int);
void main()
{
int num,f;
printf(" Enter the number : ");
scanf("%d",&num);
f=factorial(num);
printf(" Factorial %d ",f);
getch();
}
int factorial(int n)
{
if(n==1)
return 1;
}
else
return (n*factorial(n-1));
}
No comments:
Post a Comment