Factorial of a number using recursion
// factorial of a number #include <stdio.h> #include <math.h> int fact ( int ); int main (){ int num,f; printf ( "enter the number:" ); scanf ( "%d" ,&num); f= fact (num); printf ( "\n Factorial of (%d) is (%d)" ,num,f); } int fact ( int f) { if (f== 1 ) return f; else return f*(f- 1 ); }

Comments
Post a Comment