Below is the C++ program to find all the divisors of a number.

A divisor is a number that divides another number completely. For example D is the divisor of N if N%D=0.

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

**Output**

Enter the number: 6

Divisors of 6 are 1 2 3 6

this program can be made simple