title: Calling Boolean function in C++
body: <p>Here is my program, which aims to show whether the input integer is a perfect number or not. It is required to use Boolean function and call it back in main function. However, after running the trial, there is no output. Can anyone help out this programming newbie...Thanks in advance for any help.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  bool perfect ( int num )
  {
      int sum = 0, i = 1;
      while( i &lt; num ) {
          if ( num % i == 0 ) {
              sum = sum + i;
              i++;
          }
      }
  
      if ( num == sum )
          return 1 ;
      else
          return 0 ;
  }
  
  int main()
  {
      int num ;
      cin &gt;&gt; num ;
  
      if ( perfect ( num ) == 1 )
          cout &lt;&lt; " YES " &lt;&lt; endl ;
      else
          cout &lt;&lt; " NO " &lt;&lt; endl ;
  }
  </code></pre>