// Online C compiler to run C program online #include <stdio.h> int main() { int n; int factorial = 1; printf("Enter a number: "); scanf("%d", &n); if(n<0) printf("Error!"); else{ for(int i = 1; i <= n; ++i){ factorial *= i; } printf("Factorial of %d = %d", n,factorial); } return 0; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter