// Programe of factorial by using recursion
#include
#include
int fact(int );
void main()
{
clrscr();
int n,j;
printf("enter a number");
scanf("%d", &n);
printf(" the factorial of the number %d is %d ",n,fact(n));
getch();
}
int fact(int n)
{
int result;
if(n==0)
result=1;
else
result=n*fact(n-1);
return (result);
}
Algorithm
· Start
· Declare n, j as integer
· Write("the number")
· Read("the number”)
· Read(" the factorial of the number”)
· Stop
· Declare fact(int n), result as integer
· if(n==0)
· result=1
· else
· result=n*fact(n-1)
· return (result)
c programming sample codes
ReplyDeletec example code Calculate the Pascal triangle