Below I have shared the factorial program in C++.

Factorial is the product of a number and all the numbers below it. For example factorial of 4 is equal to 24.

If you have any problem regarding below factorial program in C++ then you can freely ask it by commenting below.

## Factorial Program in C++

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include<iostream> using namespace std; int main() { unsigned long i,fac,n; cout<<"Enter number: "; cin>>n; for(i=1,fac=1;i<=n;++i) { fac=i*fac; } cout<<"Factorial of "<<n<<" is: "<<fac; return 0; } |

**Output**

Enter number: 5

Factorial of 5 is: 120

ranjanfor(i=1;i<n;i++)

{

fac=n(n-i);

n=fac;

}

this logic will also give the same result ……

Tsionawit Tigistuproblem solved! thanks,

vishnu prakashWrite a program in c++ to read a single dimension array of size 'n' and create a 2-d array as follows:

input array: 1 2 3 4

output array: 1 0 0 1

0 2 2 0

0 3 3 0

4 0 0 4