Write a program to calculate the factorial of a number using recursion.
#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); } } |
Very simple & clear
U miss getch() ;
dffd
Visit Here ►► ►► http://lightningcode.wordpress.com/2014/08/29/c-program-to-find-factorial-of-a-number-using-recursion/
For the complete c program with explanation ..
Veeerry Clear and straight. I like that
Nice