Programming Code Center(PCC)
[CPP]

(PCC)::[How-to-write-CPP-Program-to-Display-Factors-of-a-Number]::[cpp]

File Name : Factors_of_number.cpp

//Example: Display all Factors of a Number
#include <iostream>
using namespace std;

int main()
{
    int n, i;

    cout << "Enter a positive integer: ";
    cin >> n;

    cout << "Factors of " << n << " are: " << endl;  
    for(i = 1; i <= n; ++i)
    {
        if(n % i == 0)
            cout << i << endl;
    }

    return 0;
}

Output :

Factors_of_number.jpg