write a program that finds the factorial of a number using
recursion?
Answer Posted / prasenjit banik
#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);
}
}
| Is This Answer Correct ? | 14 Yes | 9 No |
Post New Answer View All Answers
What is break statement?
please send me the code for multiplying sparse matrix using c
What is the difference between test design and test case design?
Explain the difference between ++u and u++?
explain what are pointers?
Explain how are 16- and 32-bit numbers stored?
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
Is it fine to write void main () or main () in c?
How can a process change an environment variable in its caller?
How can you convert integers to binary or hexadecimal?
Combinations of fibanocci prime series
Is the exit() function same as the return statement? Explain.
What does nil mean in c?
What is memcpy() function?
Is a house a mass structure?