title: Determine a Prime or composite number
body: <p>I'm writing a program to determine whether or not a given number is a prime number or a composite. My code below is what i have so far. I'm thinking that using a WHILE LOOP wouldn't be as efficient as a FOR LOOP but i may be wrong. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, const char* argv[]) {
      int num, i;
  
      printf("Enter a number you want to check:");
      scanf("%d", &amp;num);
      if (num == 1) {
          printf("%d is neither prime nor composite", num);
      }
      i = 2;
      while (i &lt;= num - 1) {
          if (num % i == 0) {
              printf("%d is composite\n\n", num);
              break;
          }
      }
  }
  </code></pre>
  
  <p>The program works with most even numbers but when I get to, say 9 I don't get a return because it's not dividing by three. Could i add into this WHILE LOOP to compensate or would i be easier to use a FOR LOOP?</p>
  
  <p>I'm thinking that if i used a FOR LOOP i could start it off sort of like this.</p>
  
  <pre><code>    for (i = 2, i &lt;= num, i++) {
          num % i == 0;
      }
      printf("%d is Composite", num);
  }
  </code></pre>