#include<stdio.h>
#include<conio.h>
int factorial(int n)
{
int f=1;
if(n>0)
f=n*factorial(n-1);
return f;
}
void main()
{
int num;
clrscr();
printf("\nEnter the numbert : ");
scanf("%d",&num);
printf("\nThe factorial is : %d",factorial(num));
getch();
}
Algorithm
factorial(n)
step1: start
step2: intilize f<-1 br="">step3: check whether n>0,then go to 4
else go to step 6
step4: f=n*factorial(n-1)
step5: return f
step6: stop
main()
step1: start
step2: read num
step3: print factorial(num)
step4: stop-1>
#include<conio.h>
int factorial(int n)
{
int f=1;
if(n>0)
f=n*factorial(n-1);
return f;
}
void main()
{
int num;
clrscr();
printf("\nEnter the numbert : ");
scanf("%d",&num);
printf("\nThe factorial is : %d",factorial(num));
getch();
}
Algorithm
factorial(n)
step1: start
step2: intilize f<-1 br="">step3: check whether n>0,then go to 4
else go to step 6
step4: f=n*factorial(n-1)
step5: return f
step6: stop
main()
step1: start
step2: read num
step3: print factorial(num)
step4: stop-1>