Write a program to calculate the factorial of a number using recursion.
#include<iostream.h> #include<conio.h> void main() { int n,fact; int rec(int); clrscr(); cout<<"Enter the number:->"; cin>>n; fact=rec(n); cout<<endl<<"Factorial Result are:: "<<fact<<endl; getch(); } rec(int x) { int f; if(x==1) return(x); else { f=x*rec(x-1); return(f); } }
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
int fact=1,num=1;
cout <>num;
if (num<=0);
num=1;
for(int count=1;count<=num;count++);
{ fact=*count
;
cout <<fact;
system("PAUSE");
return EXIT_SUCCESS;
}
it’s very nice ya,was helpful
very very useful C++ Program in my project
good
#include
using namespace std;
int main()
{
int n,fact;
int rec(int);
cout<”;
cin>>n;
fact=rec(n);
cout<<endl<<"Factorial Result are:: "<<fact<<endl;
return 0;
}
int rec(int x)
{
int f;
if(x==1)
return(x);
else
{
f=x*rec(x-1);
return(f);
}
}
i not satisfied
#include
#include
void fact(int)
void main()
{
int num;
cout<>num;
fact(num);
getch();
}
void fact(int n)
{
long int sum=1;
{
for(int temp=1; temp<=n; temp++)
sum=sum*temp;
}
cout<<"factorial of given no. is:";
}
not satisfied..!@#$%^&*()