Z zacha Forum Veteran Established May 24, 2022 #1 Attachments You do not have permission to view the full content of this post. Log in or register now.
Solution A A Aoshinomori May 24, 2022 C: #include <stdio.h> int main() { int n,o; unsigned long factorial=1; printf("Enter an integer: "); scanf("%d", &n); o = n; if (n < 0) { printf("Invalid number!"); } else { while (n > 0) { factorial = factorial * n; n = n - 1; } printf("\n%d! = %lu", o, factorial); } getch(); return 0; }
C: #include <stdio.h> int main() { int n,o; unsigned long factorial=1; printf("Enter an integer: "); scanf("%d", &n); o = n; if (n < 0) { printf("Invalid number!"); } else { while (n > 0) { factorial = factorial * n; n = n - 1; } printf("\n%d! = %lu", o, factorial); } getch(); return 0; }
A Aoshinomori Addict May 24, 2022 #2 C: #include <stdio.h> int main() { int n,o; unsigned long factorial=1; printf("Enter an integer: "); scanf("%d", &n); o = n; if (n < 0) { printf("Invalid number!"); } else { while (n > 0) { factorial = factorial * n; n = n - 1; } printf("\n%d! = %lu", o, factorial); } getch(); return 0; } Upvote 0 Downvote Solution
C: #include <stdio.h> int main() { int n,o; unsigned long factorial=1; printf("Enter an integer: "); scanf("%d", &n); o = n; if (n < 0) { printf("Invalid number!"); } else { while (n > 0) { factorial = factorial * n; n = n - 1; } printf("\n%d! = %lu", o, factorial); } getch(); return 0; }