C Introduction

Control Statement

- Program to check Palindrome or not
- Program to find sum of digits
- Program to Reverse a String
- Reverse a String by swapping
- Program to check largest number
- Program to find factor of a number
- Program to find largest number among n numbers
- Program to print multiplication table
- An effective way to use of Else If

Functions

Array

Pointers

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

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

- Introduction
- For Loop

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

Login

0 Comments

Inline Feedbacks

View all comments