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
shorting algorithmS
What are the benefits of organizational structure?
What is #include called?
What does the message "automatic aggregate intialization is an ansi feature" mean?
Can static variables be declared in a header file?
What is the scope of global variable in c?
Tell me is null always defined as 0(zero)?
How do shell structures work?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file
What are # preprocessor operator in c?
Write a Program to accept different goods with the number, price and date of purchase and display them
Why do we use return in c?
Who invented b language?
write a program to find out prime number using sieve case?