My program works fine and listed the 3 perfect numbers under 1000, but i need help with listing the factors of the perfect numbers. Can someone please help me out with this?

Code:`#include <iostream>`

using namespace std;

void main()

{

int n = 1000,sum = 0;

int i;

cout << "Searching for perfect number less than 1000..." << endl;

for(int num = 2; num <= n; num++)

{

sum = 0;

for(i = 1; i < num; i++)

{

if(num%i==0)

sum+=i;

}

if(sum == num)

cout << num << " Is perfect number" << endl;

}

}