C Program & Algorithm to find the factorial of a given number

September 16, 2016

This is the C program code and algorithm for finding the factorial of a given number.


Write a C program to find the factorial of a given number.


Step 1: Start
Step 2: Read number n
Step 3: Set f=1
Step 4: Repeat step 5 and step6 while n>0
Step 5: Set f=f*n
Step 6: Set n=n-1
Step 7: Print factorial f
Step 8: Stop

Program code


void main( )
clrscr( )
 int num,f=1;
 printf("Enter the number: ");

printf("The factorial is %d",f);
getch( );


Enter the number : 5

The factorial is 120
About Author
Adeeb C (219 Articles)

Adeeb C is the founder of this website. He is a blogger and web developer. And he writes about latest technology news, gadgets and windows since last four years.