An algorithm to find the factorial of any no entered through the keyboard.

1) START

2) Initialize i=1 & Fact=1

3) Enter the any number to calculate factorial as N

4) Check is i <= N if TRUE then continue ELSE Goto Step 8

5)  Fact = Fact * i

6)  increment Value of i by 1.  i.e i = i+1

7) GOTO Step 4

8) Print value of Fact

9) END

Flowchart to find the factorial of any no entered through the keyboard.

Flowchart to calculate factorial of given number
Flowchart to calculate factorial of given number.

WAP in C to find the factorial of any no entered through the keyboard.

#include<stdio.h>

void main()
{
int n,i=1,fact=1;
printf("Enter any number to calculate factorial :");
scanf("%d",&n);
while(i<=n)
    { 
         fact=fact*i;
         i++;
     }
printf("\nThe factorial of given number is %d",fact);
}

C-Code to find the factorial of any no using for loop.

#include<stdio.h>
void main()
{
int n,i,fact=1;
printf("Enter any number to calculate factorial :");
scanf("%d",&n);
for(i=1;i<=n;i++)
   {
   fact=fact*i;
   }
printf("\nThe factorial of given number is %d",fact);
}