Factorial(Recursive)
Variables used
num-The number
facto-Factorial
Program
#include<stdio.h>
main()
{
int num ,facto ;
int fact(int);
printf("Enter the Number");
scanf ("%d",&num);
facto=fact(num);
printf("Factorial of Number=%d",facto);
}
int fact(int x)
{
int y;
if(x==1)
return 1;
else
{
y= x * fact(int x-1);
return y;
}
}
Variables used
num-The number
facto-Factorial
Program
#include<stdio.h>
main()
{
int num ,facto ;
int fact(int);
printf("Enter the Number");
scanf ("%d",&num);
facto=fact(num);
printf("Factorial of Number=%d",facto);
}
int fact(int x)
{
int y;
if(x==1)
return 1;
else
{
y= x * fact(int x-1);
return y;
}
}
No comments:
Post a Comment