title: print all the amounts that can be paid using only n coins
body: <p>I have a homework problem where the user inputs a number of coins N.  The program is supposed to find all the amounts you can make if those coins could be made up of any combination of pennies, nickles, dimes, and quarters.</p>
  
  <p>I had read other posts where they recommend so much to us dynamic programming, so I used DP in my program for the solution below:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  // q(quater), d (dime), n(nickle), p(penny).
  int find_coin(int *q, int *d, int *n, int *p, int k)
  {
      int count = 0;
  
      *q = k / 25;
      count += *q;
      k = k % 25;
  
      *d = k / 10;
      count += *d;
      k = k % 10;
  
      *n = k / 5;
      count += *n;
      k = k % 5;
  
      *p = k;
      count += *p;
  
      return count;
  }
  
  int main() {
      int q,d,n,p;
      int k = 0;
      int i = 0;
      int counts = 0;
      puts("\nEnter a number of coins: ");
      scanf("%d", &amp;k);
  
      find_coin(&amp;q, &amp;d, &amp;n, &amp;p, k);
  
      printf("%3d cents:\t", k);
      printf("total of pennies: %d    ",p);
      printf("total of nickles: %d    ",n);
      printf("total of Dimes: %d      ",d);
      printf("total of quaters: %d  \n",q);
      getchar();
  }
  </code></pre>
  
  <p>My output is:</p>
  
  <pre><code>Enter a number of coins:
  5
    5 cents:      total of pennies: 0    total of nickles: 1      total of Dimes: 0       total of quaters: 0
  </code></pre>
  
  <p>But my professor now asks me for this output:</p>
  
  <pre><code>Enter the number of coins
  2
  2 cents: 0 quarters 0 dimes 0 nickels 2 pennies
  6 cents: 0 quarters 0 dimes 1 nickels 1 pennies
  11 cents: 0 quarters 1 dimes 0 nickels 1 pennies
  15 cents: 0 quarters 1 dimes 1 nickels 0 pennies
  20 cents: 0 quarters 2 dimes 0 nickels 0 pennies
  26 cents: 1 quarters 0 dimes 0 nickels 1 pennies
  30 cents: 1 quarters 0 dimes 1 nickels 0 pennies
  35 cents: 1 quarters 1 dimes 0 nickels 0 pennies
  50 cents: 2 quarters 0 dimes 0 nickels 0 pennies
  </code></pre>
  
  <p>I tried my solution using a loop, but my loop is incorrect. I did something wrong in the code where the loop is just overloading:</p>
  
  <pre><code>for(i = 1; i &gt; counts; i++) {     
       printf("%3d cents:\t", k);
       printf("total of pennies: %d    ",p);
       printf("total of nickles: %d    ",n);
       printf("total of Dimes: %d      ",d);
       printf("total of quaters: %d  \n",q);
       k++;
  }
  </code></pre>