Virajsinh

FileHandling_11

Nov 17th, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include<conio.h>
  2. #include<stdio.h>
  3.  
  4. int factorial (int);
  5. void main()
  6. {
  7.  
  8.     int fact, n;
  9.     clrscr();
  10.  
  11.     printf("\n Enter Num : ");
  12.     scanf("%d",&n);
  13.     fact=factorial(n);
  14.     printf("\n The Factorial Of");
  15.     printf(" %d is   %d", n, fact);
  16.     getch();
  17. }
  18.  
  19.     int factorial (int n)
  20.     {
  21.         if(n < 1)
  22.         {
  23.             return 1;
  24.         }
  25.  
  26.         else
  27.         {
  28.             return(n * factorial(n - 1));
  29.         }
  30.     }
Add Comment
Please, Sign In to add comment