fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int num,fact=0;
  5. printf("Enter a number.\n");
  6. scanf("%d",&num);
  7. while(num)
  8. {
  9. fact=num*(num-1);
  10. --num;
  11. }
  12. printf("The factorial of the given number is %d.",num);
  13. return 0;
  14. }
Success #stdin #stdout 0.01s 1724KB
stdin
5
stdout
Enter a number.
The factorial of the given number is 0.