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);
}
} |
#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);
}
}
Editorial Team
We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.
#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;
}
wat does cout means??
It is bloody fucking wrong.it is really a fuck sandwich
, the provided fuotcinn _might_ work as you expect, but it doesn’t _have_ to, so it’s just plain wrong. No sense talking about the efficiency of your code if there is such a major flaw in it -disclaimer-If you the code you gave here does not match up with the code you gave your interviewer, this whole rant makes no sense at all, but it should just match up. Honestly, though, it makes a whole lot of sense to me if that error was the reason you were shown the door, seeing that an inefficiency would not exactly constitute much of a reason to be _that_ convinced you aren’t qualified for the job
#include
#include
#include
long int fact(int);
void main()
{
int n;
long int f=1;
clrscr();
cout<>n;
f=fact(n);
cout<<"\n\nThe factorial of "<<n << " is "<<f;
getch();
}
long int fact(int n)
{
long int f=1;
if(n==1||n==0)
return(1);
else
{
f=n*fact(n-1);
return(f);
}
}
plz publsh smhng btr thn ths
kch bhi mat likha kro…:p
faltu fokat mae dimag ka dahi na kr..vrna ungli krna mje bhi ata h…;)
Thank you so much for providing individuals with an extraordinarily breathtaking possiblity to discover important secrets from this blog. It really is very terrific and stuffed with fun for me personally and my office peers to visit your web site minimum 3 times in 7 days to study the latest items you have. Of course, we are at all times fulfilled with all the striking secrets you serve. Selected 2 points on this page are completely the most impressive we have ever had. test2 http://testdomain.com
Thank you so much for this program
Thank you
thanks for this program to give us……
thanx for providing this
Very simple & clear
U miss getch() ;
dffd
Visit Here ►► ►► http://lightningcode.wordpress.com/2014/08/29/c-program-to-find-factorial-of-a-number-using-recursion/
For the complete c program with explanation ..
Veeerry Clear and straight. I like that
Nice
Its simple and clearing all topics awesom