C Program to Calculate Factorial of a Number



Factorial of an integer is the product of the integer and all the integers below it; e.g. factorial five ( 5! ) is equal to (5*4*3*2*1) =120.



  1. //C Program to calculate factorial of a number
  2. #include<stdio.h>
  3. int main()
  4. {
  5. int n, i, fact=1;
  6. printf("Enter a number: ");
  7. scanf("%d", &n);
  8. for (i=1; i<=n; i++)
  9. {
  10. fact=fact*i;
  11. }
  12. printf("Factorial = %d", fact);
  13. return 0;
  14. }

Output
Output!
download android app

Popular C Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube