title: Nested for loop in C not working as expected
body: <pre><code>for (i = 2; i &lt; input; i++){
      for (d = 2; d &lt; input; d++){
          product = d*i;
          printf("%d\n", product);
          break;
      }
  }
  </code></pre>
  
  <p>This snippet of code is part of my solution to a homework question for my Intro to C class. The actual question is something involving prime numbers, but the solution that I thought of requires the use of for loops nested like this. I can't get them to behave correctly, though. I assume using an array would simplify things, but we haven't taken them up yet and are not allowed to use them in our solution. Anyway:</p>
  
  <p>If, for example, my input is 10, my values of <code>i</code> should be {2,3,4,5,6,7,8,9}. My values for <code>d</code> should also be {2,3,4,5,6,7,8,9}. </p>
  
  <p>What I expect this loop to do is multiply each <code>i</code> by the full loop of <code>d</code>:</p>
  
  <pre><code>2*2
  2*3
  2*4
  .
  .
  .
  2*9
  3*2
  3*3
  .
  .
  .
  .
  </code></pre>
  
  <p>and onwards. However, it is instead just multiplying <code>i</code> by <code>d = 2</code>, and I get the following:</p>
  
  <pre><code>4
  6
  8
  10
  .
  .
  .
  20
  </code></pre>
  
  <p>What am I doing wrong?</p>