Pages

Oct 7, 2011

wap in C++ to find factorial using recurssion.

#include<iostream.h>
#include<conio.h>
long fact(int);
void main()
{
clrscr();
int num,y;
cout<<"\nEnter a positve integer:\t";
cin>>num;
y=fact(num);
cout<<"\nFactorial of\t"<<num<<"\t"<<y;
getch();
}


long fact(int n)
{
if(n==0)
return 1;
return (n*fact(n-1));
}