Guest User

Untitled

a guest
Aug 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int factorial(int n)
  4. {
  5. if(n == 0){return 1;}
  6. else { return n*(factorial(n-1));}
  7. }
  8.  
  9. int main()
  10. {
  11. int x = 0;
  12. char answer = 'Y';
  13.  
  14. while(answer == 'Y')
  15. {
  16. printf("input a number to see its factorial : ");
  17. scanf("%d", &x);
  18. int output = factorial(x);
  19. printf("%d\n", output);
  20.  
  21. printf("Would you like to continue Y/N : ");
  22. scanf("%c", &answer);
  23. printf("\n")
  24. }
  25.  
  26. return 1;
  27. }
Add Comment
Please, Sign In to add comment