title: Printing prime numbers from 1 through 100
body: <p>This c++ code prints out the following prime numbers:   <strong>3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97.</strong></p>
  
  <p>But I don't think that's the way my book wants it to be written. It mentions something about square root of a number. So I did try changing my 2nd loop to <code>for (int j=2; j&lt;sqrt(i); j++)</code> but it did not give me the result I needed.</p>
  
  <p>How would I need to change this code to the way my book wants it to be?</p>
  
  <pre><code>int main () 
  {
      for (int i=2; i&lt;100; i++) 
          for (int j=2; j&lt;i; j++)
          {
              if (i % j == 0) 
                  break;
              else if (i == j+1)
                  cout &lt;&lt; i &lt;&lt; " ";
  
          }   
      return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>A prime integer number is one that has
    exactly two different divisors, 
    namely 1 and the number itself. Write,
    run, and test a C++ program that 
    finds and prints all the prime numbers
    less than 100. (Hint: 1 is a  prime
    number. For each number from 2 to 100,
    find Remainder = Number % n, where n
    ranges from 2 to sqrt(number). \ If n
    is greater than sqrt(number), the
    number is not equally divisible by n. 
    Why? If any Remainder equals 0, the
    number is no a prime number.)</p>
  </blockquote>