fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int x, i, f = 1;
  5. printf("Enter a value for x: \n");
  6. scanf("%d", &x);
  7.  
  8. for(i = 1; i <= x; ++i)
  9. {
  10. f*=i;
  11. }
  12. printf("\nFactorial of %d is %d", x, f);
  13.  
  14. return 0;
  15. }
  16.  
Success #stdin #stdout 0s 4324KB
stdin
4
stdout
Enter a value for x: 

Factorial of 4 is 24