Program to find factorial of any no using Recursion
#include<iostream.h>
#include<conio.h>
int fact(int);
void main()
{
clrscr();
int b;
cout<<"\nEnter a number u want to find factorial: ";
cin>>b;
cout<<fact(b);
}
int fact(int a)
{
if(a==1)
return 1;
else
return (a*(fact(a-1)));
}
#include<conio.h>
int fact(int);
void main()
{
clrscr();
int b;
cout<<"\nEnter a number u want to find factorial: ";
cin>>b;
cout<<fact(b);
}
int fact(int a)
{
if(a==1)
return 1;
else
return (a*(fact(a-1)));
}
Post a Comment