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
Write a program for Overriding.
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
Define Array of pointers.
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What the advantages of using Unions?
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
Why do we use static in c?
How are portions of a program disabled in demo versions?
What does %p mean?
Is javascript written in c?
why do some people write if(0 == x) instead of if(x == 0)?
How does selection sort work in c?
main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }
What is dangling pointer in c?
What is the difference between text files and binary files?