C program to find the factorial using function

C program to find the factorial of a given number using function

This page has included a C program to find the factorial of any given integer number using function. The Function is a user defined function. The function is used in the program to calculate the Factorial of number. Factorial of a number is denoted by n!.  Factorial is the product of all positive integers less than and equal to the number. For example, 4! = 4 × 3 × 2 × 1 = 24. Moreover, the factorial can be calculated only for positive integers. The below given C program will find the Factorial of a number using function.  Kindly check out the program to find the Factorial of a number using function.


Factorial program using function


#include<stdio.h>
long int Factori(int);
int main(){
        long int fact;
        int numbr;

        printf("Enter a number: ");
        scanf("%d",&numbr);
        fact= Factori(numbr);
        printf("Factorial of %d is: %ld",numbr,fact);
        return 0;
}

long int Factori(int n){
         int i;
         long int factorial;
         factorial =1;
         for(i=1;i<=n;i++)
         factorial=factorial*i;
         return(factorial);
    }

 


Sample Output:

Enter a number:  4

Factorial of  4 is: 24

Enter a number:  6

Factorial of  6 is: 720


Factorial using Function

The above C program will find the factorial using function. Kindly use the program to find the factorial using function.

Other Related C Programs :


* C Program to find whether the given number is Odd or Even

* C Program to find the Sum of Odd Digits

* C Program to find the Sum of Even Digits

* C Program to find the Sum of Even and Odd Digits,

* C Program to Display Odd digits

* C Program to Display even digits

* C Program to Display Odd Numbers,

* C Program to Display Even Numbers,

* C Program to Check whether the given number is Armstrong number

* C Program to display the Armstrong numbers in Range

* C Program to display the Armstrong numbers between 1 and 1000

* C Program to check perfect number, perfect numbers in range

* C Program to Check Prime number, Prime numbers between 1 and 100

* C Program to display the Prime numbers in a Range

* C Program to display the Sum of Prime numbers

* C Program to Check Strong number

* C Program to display the Strong number in Range

* C Program to Check whether the given number is polindrome number or not

* C Program to Check polindrome number using for loop

* C Program to Check polindrome number using Recursion

* C Program to  check whether the given string is polindrome or not

* C Program to find the Roots of Quadratic equation

* C Program to display Fibonacci Series

* C Program to display the Fibonacci Series using an array

* C Program to display the Fibonacci Series using while loop

* C Program to find the Sum of Fibonacci Series, Factorial of Number

* C Program to find the Factorial without using Recursion

* C Program to find the Factorial using Pointers

* C Program to find the Factorial using Function

Bookmark and Share