Tuesday, 7 May 2013

Program In C To Find Factorial Of A Number Using Recursion


#include<stdio.h>

int func(int x)

{

int f;
if (x==1)
return (1);
else
f=x*func(x-1);
return (f);
}
void main()

{

int a, fact;



printf("\nEnter any number: ");

scanf ("%d", &a);

fact=func(a);

printf("\nFactorial Value = %d", fact);



}


1 comment:

  1. Hey, I also have a very interesting program to calculate the factorial of any number, no matters whether the number is very large, like if you wish to calculate the factorial of 500, my program will calculate it, and even it gives each and every digit of the result. for details and source code visit http://codingloverlavi.blogspot.in/2013/03/here-is-one-more-interesting-program.html
    hope you would like it.
    You can find some other simple programs for factorial on the following links:-
    http://codingloverlavi.blogspot.in/2013/05/recursive-program-for-factorial.html
    http://codingloverlavi.blogspot.in/2013/05/factorial-calculation-without-any.html

    ReplyDelete