daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. int facto(int n)
  3. {
  4.     if(n == 0)
  5.     {
  6.         return 1;
  7.     }
  8.     else if(n == 1)
  9.     {
  10.         return 1;
  11.     }
  12.     else
  13.     {
  14.         return n * facto(n-1);
  15.     }
  16. }
  17.  
  18. int main()
  19. {
  20.     int n,ans;
  21.     printf("Enter the number to find factorial: ");
  22.     scanf("%d",&n);
  23.     ans = facto(n);
  24.     printf("%d ! = %d",n,ans);
  25.     getch();
  26.     return(0);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top