title: program which check perfect numbers - something gets wrong
body: <p>I have to write a function which gets a number, and prints all the perfect numbers that are smaller than the number given. If there are not any, the function prints an appropriate message.
  The program I have just written is compiled well, but it's working only partially. If the input number is 5, for instance, for some reason I don't get any message that there are not perfect numbers in this range (=until 5) .</p>
  
  <p>Can someone please explain to me what's wrong in this program?
  I would appreciate any help!</p>
  
  <pre><code>#include&lt;iostream&gt;
  
  using namespace std;
  void check (int num, int &amp; j);
  void main()
  {
  
   int num,j, count;
  
   cout &lt;&lt; "List all the perfect numbers less than: ";
   cin &gt;&gt; num;
  
   check (num, j);
  }
  
  
   void check (int num, int &amp; j)
   {
       int i,sum, count=0;
   for(j=2;j&lt;num;num++)
   {
       sum=0;
     for(i=1;i&lt;j;i++)
     { 
        if(j%i == 0)
        sum += i; 
     }
  
      if(sum == j)
      {cout &lt;&lt; j &lt;&lt;endl; 
      count+=1;
      }
   }   
  
   if (count==0)
       cout&lt;&lt;"there are no perfect numbers"&lt;&lt;endl;
   }
  </code></pre>