rodan0818

Finding Factorial Using C Program

Jun 13th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include<stdio.h>
  2. int fact (int n)
  3. {
  4.     if (n==0||n==1)
  5.     {
  6.         return 1;
  7.     }
  8.     else
  9.     {
  10.         return (n*fact(n-1));
  11.     }
  12. }
  13.  
  14. int main(void)
  15. {
  16.     int n;
  17.     printf("Enter the Number to find its factorial \n");
  18.     scanf("%d",&n);
  19.     printf("The Factorial is %d \n",fact(n));
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment