Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int factorial(int n)
- {
- if(n == 0){return 1;}
- else { return n*(factorial(n-1));}
- }
- int main()
- {
- int x = 0;
- char answer = 'Y';
- while(answer == 'Y')
- {
- printf("input a number to see its factorial : ");
- scanf("%d", &x);
- int output = factorial(x);
- printf("%d\n", output);
- printf("Would you like to continue Y/N : ");
- scanf("%c", &answer);
- printf("\n")
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment