title: What is the problem with this boolean function?
body: <p>I was wondering what I may have done wrong in writing this simple function which is supposed to return true if the given number is a prime, or false if not a prime.</p>
  <pre><code>bool isPrime(int num)
  {
      if (num &lt;= 1)
      {
          status = false;
      }
      else
      {
          for (int i = 1; i &lt;= num; i++)
          {
              if (num % i == 0)
              {
                  dividers++;
              }
          }
          if (dividers == 2)
          {
              status = true;
          }
          else 
          {
              status = false;
          }
      }
      return status;
  }
  </code></pre>
  <p>Obviously, my main looks like this:</p>
  <pre><code>bool isPrime(int num);
  bool status;
  int dividers = 0;
  
  int main() {
  
      isPrime(2);
      if (!isPrime)
      {
          std::cout &lt;&lt; &quot;Not prime&quot; &lt;&lt; std::endl;
      }
      else
      {
          std::cout &lt;&lt; &quot;Prime&quot; &lt;&lt; std::endl;
      }
  
      return 0;
  }
  </code></pre>
  <p>I'm a C++ beginner and I'd really appreciate it if someone could help me there and correct my logic.
  Have a good day:)</p>