When a function calls itself repeatedly, until some specified condition is met then this process is process is called as recursion.Lets have a program to find the factorial using recursion in c++.
CODE:
#include<iostream.h> #include<conio.h> void main() { Clrscr(); int fact(int); int f,n; cout<<"Enter the value to find factorial "; cin>>n; f=fact(n); cout<<"Factorial is "<<f<<endl; getch(); } int fact (int n) { int value=1; if (n==1) return value; // Base Case else { value=n*fact(n-1); // General Case- Calls the function itself return value; }}
1 comments:
New York casinos, sports betting, hotel, gaming - DRMCD
New York's casinos and sports betting options are coming to a 김포 출장안마 real-time and 울산광역 출장안마 free online gaming destination. We look forward 순천 출장안마 to seeing you 과천 출장마사지 at 대전광역 출장안마
Post a Comment