Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void main()
- {
- while (1)
- {
- int n,i,product=1;
- printf("Enter value: ");
- scanf("%d",&n);
- if (n>0)
- {
- for (i=n;i>0;i--)
- {
- product*=i;
- }
- printf("Factorial = %d\n",product);
- }
- else if (n==0)
- printf("Factorial = 1\n");
- else
- printf("Undefined value\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement