Below is C program to Factorial by Recursion .
Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* Factorial by Recursion */ #include<stdio.h> int fact( int ); int main() { int n; printf ( "Type any value : " ); scanf ( "%d" ,&n); n=fact(n); printf ( "\nFactorial : %d " ,n); return 0; } int fact( int x) { if (x==1) return (x); else x=x*fact(x-1); } |
No comments:
Post a Comment