2. Finding Factorial of a number using Recursion(or Recursive - TopicsExpress



          

2. Finding Factorial of a number using Recursion(or Recursive Function) Recursive Function : Recursive function is a type of function which calls itself in Function Definition Code Segment until a terminating condition reached. In the following program "fact( )" is a recursive function. void main() { int number,ans; clrscr(); printf("Enter the number"); scanf("%d",&number); ans=fact(number); printf(" factorial=%d",ans); getch(); } int fact(int n) { int f; if(n==1) return (1); else f=n*fact(n-1); return (f); } //Use long int in place of int to find factorial of large number like 100 or so on..
Posted on: Sat, 28 Sep 2013 05:11:49 +0000

Trending Topics



Recently Viewed Topics




© 2015