# Program that calculate the factorial value of any number by using functions

# Program that calculate the factorial value using functions

### Object: Write a function to calculate the factorial value of any integer entered through the keyboard. C++ projects for beginners with source code

## Code:

**#include<iostream>**

**#include<conio.h>**

**using namespace std;**

**int fac(int num);**

**void main()**

**{**

**int nu;**

**cout<<“\nEnter Any Number: “;**

**cin>>nu;**

**cout<<fac(nu);**

**getch();**

**}**

**int fac(int num)**

**{**

**int i,fact=1;**

**for(i=num;i>=1;i–)**

**{**

**fact=fact*i;**

**}**

**cout<<“\nFactorial of given Number is: “;**

**return fact;**

**}**

#include<iostream> #include<conio.h> using namespace std; int fac(int num); void main() { int nu; cout<<"\nEnter Any Number: "; cin>>nu; cout<<fac(nu); getch(); } int fac(int num) { int i,fact=1; for(i=num;i>=1;i--) { fact=fact*i; } cout<<"\nFactorial of given Number is: "; return fact; }

## 1 Response

[…] Program that calculate the factorial value of any number by using functions […]