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
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
What is malloc() function?
What is #include cctype?
What is the role of && operator in a program code?
How can I read a binary data file properly?
What are qualifiers in c?
Explain how do you determine the length of a string value that was stored in a variable?
Suggesting that there can be 62 seconds in a minute?
Difference between macros and inline functions? Can a function be forced as inline?
Do you have any idea about the use of "auto" keyword?
What functions are used for dynamic memory allocation in c language?
Hai what is the different types of versions and their differences
Explain how can I convert a number to a string?
Is it better to use malloc() or calloc()?
How do you list files in a directory?