title: Determining if a number is prime
body: <p>I have perused a lot of code on this topic, but most of them produce the numbers that are prime all the way up to the input number.  However, I need code which only checks whether the given input number is prime.</p>
  
  <p>Here is what I was able to write, but it does not work:</p>
  
  <pre><code>void primenumber(int number)
  {
      if(number%2!=0)
        cout&lt;&lt;"Number is prime:"&lt;&lt;endl;
      else 
        cout&lt;&lt;"number is NOt prime"&lt;&lt;endl;
  }
  </code></pre>
  
  <p>I would appreciate if someone could give me advice on how to make this work properly.</p>
  
  <h3>Update</h3>
  
  <p>I modified it to check on all the numbers in a for loop.</p>
  
  <pre><code>void primenumber(int number)
  {
      for(int i=1; i&lt;number; i++)
      {
         if(number%i!=0)
            cout&lt;&lt;"Number is prime:"&lt;&lt;endl;
         else 
            cout&lt;&lt;"number is NOt prime"&lt;&lt;endl;
      }  
  }
  </code></pre>