# 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.

**Aim:**

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

**Algorithm:**

Step 1:StartStep 2:Read numbernStep 3:Set f=1Step 4:Repeat step 5 and step6 while n>0Step 5:Set f=f*nStep 6:Set n=n-1Step 7:Print factorialfStep 8:Stop

**Program code**

#include<stdio.h> #include<conio.h> void main( ) { clrscr( ) int num,f=1; printf("Enter the number: "); scanf("%d",&num); while(n>0) { f=f*n; n--; } printf("The factorial is %d",f); getch( ); }

**Output**

Enter the number : 5 The factorial is 120