Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. int main()
  7. {
  8.   int n,i;
  9.   int res;
  10.  
  11.   unsigned long long fact = 1;
  12.   printf("Enter number: ");
  13.   scanf("%d",&n);
  14.  
  15.   if(n >= -7 && n <= 7)
  16.   {
  17.     if(n <= 0)
  18.     {
  19.       printf("Error");
  20.     }
  21.  
  22.     else
  23.     {
  24.       for(i = 1; i <= n; i++)
  25.       {
  26.         fact *= i;
  27.       }
  28.     }
  29.    
  30.     printf("%llu\n", fact);
  31.   }
  32.  
  33.   else
  34.   {
  35.     printf("Error");
  36.   }
  37.   _getch();
  38.   return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement