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

**}**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #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 […]