/* Factorial of a number using recursive function */
#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int num;
printf("Enter A Number:");
scanf("%d",&num);
printf("\n%d!=%d",num,fact(num));
getch();
}
fact(int num)
{
if(num<1)
{
return 1;
}
else
{
return (num*fact(num-1));
}
}
0 comments:
Post a Comment