Friday, 2 November 2012

C Program to print the Factorial of a given number using recursion

Write a C program to find the factorial of a given number with recursion

The sample output for finding factorial value using recursion is shown below.

What is meant by Recursion ?
A function that calls itself is known as recursive function and the process of calling function itself again and again is known as recursion in C programming.

In this factorial program the function fact is recursive because it calls itself.
suppose If you want to find the factorial value for 5. then fact(5)=5*fact(4).to solve this we need the value for fact(4) is nothing but 4*fact(3) likes that its goes on,finally we got fact(5)=5*4*3*2*1=120.


Post a Comment

Related Posts Plugin for WordPress, Blogger...