title: How to do a loop with specific (irregular) steps in C?
body: <p>I wrote the following function in C for a greedy algorithm (‘change‘ and 'numberCoins' are global variables).</p>
  <pre><code>int calculateNumber(void)
  {
      numberCoins += change / 25;
      change = change % 25;
  
      numberCoins += change / 10;
      change = change % 10;
  
      numberCoins += change / 5;
      change = change % 5;
  
      numberCoins += change / 1;
      change = change % 1;
  
      return 0;
  } 
  </code></pre>
  <p>It works fine. However, the copy and paste disturbs me. Is there a possibility to write that without as much repetition? My idea was to write it in a loop. But I couldn't find out how to do a loop with irregular steps. My idea looked like this (how do I make it, that i gets assigned 25 in the first itiration, then 15, then 10 and then 1)?</p>
  <pre><code>for (int i = 25; i &gt;= 5; ???)
      {
          numberCoins += change / i;
          change = change % i;
      }
  </code></pre>
  <p>Thank you for your help.</p>