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
April 6th, 2010 at 11:00 pm
#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;
}
March 15th, 2011 at 7:46 am
it’s very nice ya,was helpful
May 10th, 2011 at 10:02 am
very very useful C++ Program in my project
August 2nd, 2011 at 8:47 pm
good
November 4th, 2011 at 4:13 pm
#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);
}
}
January 2nd, 2012 at 11:11 am
i not satisfied