I am new to C++ programming and have a problem with one of my programs

```
#include <iostream>
using namespace std;
bool IsPerfect(int n);

int main ()
{
  for(int i=1; i<100; i++){
    IsPerfect(i);
  }

  return 0;
}

bool IsPerfect(int n){
  int sum;
  for(int x=1; x<n; x++){
    if(n%x==0){
      sum+=x;
      return true;
      cout <<n;
    }
    else{
      return false;
    }
  }
}

```

I am trying to create a program that will list perfect numbers but I can't find the bug as to why it would not print.