Write a program using recursion to find factorial of a number.
Ajink Gupta Answered question April 13, 2024
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # include <stdio.h> # include <conio.h> int fact(int); int main() { int x,n; clrscr(); printf( " Enter the Number to Find Factorial :" ); scanf( "%d" ,&n); x=fact(n); printf( " Factorial of %d is %d" ,n,x); return 0; getch(); } int fact(int n) { if (n==0) return (1); return (n*fact(n-1)); } |
Ajink Gupta Answered question April 13, 2024