Factorial Number

#include<stdio.h>
#include<conio.h>
Int fact(int);
void main()
{
Int s,n;
Clrscr();
Printf ("enter the number");
Printf("%d",&n);
s=fact(n);
Printf("The factorial is %d",s);
getch();
}
Int fact(int n)
{
Int f;
if(n==1)
{
return 1;
}
Else
{
f=n*fact(n-1);
return f;
}
}
Output:
              Enter the number
                           5
              The factorial is 120



Comments

Post a Comment

Popular posts from this blog

Scan Converting a sStraight Line

DDA and Bresenham's Algorithm

priority&non priority scheduling