Write a cpp program to print factorial using recurtion?

#include<iostream.h>
#include<conio.h>
long fact(int n)
{
 if(n>0)
  return(n*fact(n-1));
 else
  return(1);
}
void main()
{
 clrscr();
 int f=fact(5);
 cout<<"Factorial of 5 is: "<<f;
 getch();
}

Ourput:



Comments

Popular posts from this blog

Larch Soft Pvt. Ltd. - Best Website & Hosting Provider