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


Please Help Members By Posting Answers For Below Questions

shorting algorithmS

1803


What are the benefits of organizational structure?

574


What is #include called?

569


What does the message "automatic aggregate intialization is an ansi feature" mean?

694


Can static variables be declared in a header file?

618






What is the scope of global variable in c?

558


Tell me is null always defined as 0(zero)?

674


How do shell structures work?

569


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)

689


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

668


What are # preprocessor operator in c?

632


Write a Program to accept different goods with the number, price and date of purchase and display them

5452


Why do we use return in c?

569


Who invented b language?

919


write a program to find out prime number using sieve case?

1642