C program to print factorial of any number by using while loop.

Let’s write a program which print factorial of any number.


Step 1: Let’s open turbo c and write the following code.


// Add preprocessor



void main()


int  n,i=1;

long int  fact=1;


// Clear screen



printf(“enter any number:”);








// print the result

printf(“ factorial is: %li”,fact);






Step 2: Now save it by pressing F2 and name it FACTORIAL.CPP.



Step 3: Compile it by pressing ALT+F9 to check errors in program.



Step 4: Run the program and see output.









Enjoy  coding.









Tags: , ,

  • Aman Rustagi

    Thanks .. nice program. The factorial of a integer N, denoted by N! is the product of all positive integers less than or equal to n. Factorial does not exist for negative numbers and factorial of 0 is 1. We can also find factorial of a number using recursion.
    factorial(N) = factorial(N-1) x N

  • Pingback: Maria Smith()