Description

Hello Guys..

Welcome to lapmos.com

Today we will write a program which is how to calculate the factorial of  a number given by user. First of all we should know what is factorial?

Factorial is a function that multiplies the number by every number below till 1. It's denoted by ( n! ).

For Example : 3! = 3 * 2 * 1 = 6

factorial of 0 (zero) is 1 = 0! = 1

Now Let's Start the Code.....

#include<stdio.h>

int main(){
    int n;
    printf("Enter the number : ");
    scanf("%d", &n);
    
    int fact = 1;
    for(int i=1; i<=n; i++){
        fact = fact * i;
    }
    printf("The factorial of %d! is %d", n, fact);
    return 0;
}

Output :

Enter the number : 5
The factorial of 5! is 120

Comments

Login is mandatory to comment Please login

Recommended Posts

Factorial Using function | C programming language

Here we calculate the factorial using function in c programming language.

Prime number program in c | Calculate given number is prime or Not | prime number

What is prime number? and how to calculate the given number is prime or not |

Largest Number | C programming language

Hello guys.. Today we write a program how to find the largest number ( greatest number ) in array c programming language.

Swap two number | C programming

Write a c program swap two number given by user.

Swap two number without using third variable | C programming language

Write a program Swap two number withtout using third variable in c programming language.

Fibonacci Series | Fibonacci Series in C | @lapmos

Fibonacci numbers ( sequence ) is a set of numbers that start with 1 or 0 followed by a 1 proceeds on the rule that each number.