title: program to print 1-100 prime number and throw exception for composite number in given range
body: <p>i have made a program to print 1-100 prime numbers.
  please help me to throw exception for composite number in range of 1-100 numbers.
  i am a beginner so any help will be appreciated. </p>
  
  <pre><code>  public static void main(String[] args) {
  
      System.out.println("Prime numbers from 1 - 100 are :");
      int i = 0;
      int x = 0;
  
      for (i = 1; i &lt;= 100; i++) {
  
          int ctr = 0;
          for (x = i; x &gt;= 1; x--) {
              if (i % x == 0) {
                  ctr = ctr + 1;
              }
          }
          if (ctr == 2) {
              System.out.println(i);
          }
  
      }
  
  }
  </code></pre>