Courses

### Courses

Structure and Union

No Examples found for this topic - CodeHelpPro

Data Files

No Examples found for this topic - CodeHelpPro

# Program to find factorial of number

0 Suresh Chand June 2, 2021

In this example, We will learn a program to find factorial of number using loop. Before that, You must have knowledge in following topics

## Algorithm

This is the algorithm of program to find factorial of a number

```Step 1: Start

Step 2: Initialize 3 variables fact = 1, i and n

Step 3: Take input from user and assign to variable n

Step 4: Assign i  = 1

Step 5: Repeat this STEP until i <= n

Step 5.1: fact = fact * i

Step 5.2: i++

Step 6: Print fact

Step 7: End```

## Flowchart

This is the flowchart of program to find factorial of a number

## CODE: Program to find factorial of number

We will find factorial of number using for loop.

``````#include<stdio.h>

int main(){

int fact, i, n;
fact = 1;

printf("Enter the number : ");
scanf("%d" , &n);

for(i = 1; i <= n; i++){
fact = fact*i;
}

printf("\nFactorial of %d is %d", n , fact);

return 0;

}``````

The output of above program is

``````Enter the number : 5
Factorial of 5 is 120``````
Subscribe
Notify of
Inline Feedbacks