title: Why do these arrays give me a slightly different answer than this original c code?
body: <p>Okay, I'm new so thank you in advance for the help. I'm trying to improve some code I did for a class as I lean arrays. Here is the old code, followed by the loop using arrays that I would like to use. The code is for credit card validation, and the sums are off by 2. I used this fictitious credit card number: 376323472524349 for my testing. Any idea what I have done wrong?</p>
  <p>Old code I want to improve:</p>
  <pre><code>int c1, c2, c3, c4, c5, c6, c7, c8;
  c1 = ((get_card % 100) / 10) * 2;
  c2 = ((get_card % 10000) / 1000) * 2;
  c3 = ((get_card % 1000000) / 100000) * 2;
  c4 = ((get_card % 100000000) / 10000000) * 2;
  c5 = ((get_card % 10000000000) / 1000000000) * 2;
  c6 = ((get_card % 1000000000000) / 100000000000) * 2;
  c7 = ((get_card % 100000000000000) / 10000000000000) * 2;
  c8 = ((get_card % 10000000000000000) / 1000000000000000) * 2; 
  </code></pre>
  <p>What I've been trying (compiles, but the answer is slightly off):</p>
  <pre><code>int n = 10;
  int c[8];
  
      for (int i = 0; i &lt; 7 ; i++)
      {
      c[i] = ((get_card % (n*10)) / n) * 2;
      n = n * 100;
      }
  </code></pre>
  <p>Thank you!</p>