In this post, we will write a **C++ program to find out the factors of a given number**. the first user will enter the number and then the program will print the factors of a given number.

## C++ program to find out the factors of a given number.

```
#include<iostream>
#include<conio.h>
int main()
{
system("cls");
int n,i,j,res;
std::cout<<"Enter any number = ";
std::cin>>n;
for(i=1;i<=20;i++)
for(j=2;j<=i;j++)
if(n%j == 0)
{
std::cout<<j<<std::endl;
n = n/j;
}
getch();
return 0;
}
```

### Output

Enter any number = 18 2 3 3

## 0 Comments