Welcome to W3Courses
 Like Us on Facebook

Source Code for Calculating Factorial of a Number using a For Loop in C Programming

Following is the source code for calculating the factorial of a number using a For Loop in C Programming.

main()
{
      int a,b;
      printf("Enter a number between 0 and 33: ");
      scanf("%d",&a);
      b=1;
      if (a<=33)
     {
           for(;a>=1;a--)
               b*=a;
           printf("%d\n",b);
     }
     else
           printf("Not a valid number");
}

Share