title: How to write a C program to calculate total amount of money?
body: <p>I'm trying to write a program  that asks the user to input the number of coins that the user has and then output the total amount of money the user has. So it will be that the user has dimes, nickels, pennies and quarters only.  After the user enters the number of coins for each denomination, the program should output the total amount of money.</p>
  <pre><code>    #include &quot;Coins Project.h&quot;
      #include &lt;stdio.h&gt;
   
      int change(float total, int *quarters, int *dimes, int *nickels, int 
      *pennies);
      void print(float total, int quarters, int dimes, int nickels, int 
      pennies);
   
      int main(void)
      {
      int quarters, dimes, nickels, pennies;
      float total;
   
      total = 1.88;
      change(total, &amp;quarters, &amp;dimes, &amp;nickels, &amp;pennies);
      print(total, quarters, dimes, nickels, pennies);
   
      total = 0.32;
      change(total, &amp;quarters, &amp;dimes, &amp;nickels, &amp;pennies);
      print(total, quarters, dimes, nickels, pennies);
   
      printf(&quot;\nPlease enter an amount of money: \n&quot;);
      scanf(&quot;%f&quot;, &amp;total);
   
      change(total, &amp;quarters, &amp;dimes, &amp;nickels, &amp;pennies);
      print(total, quarters, dimes, nickels, pennies);
   
      return 0;
      }
   
      int change(float total, int *quarters, int *dimes, int *nickels, int 
      *pennies)
      {
      if( total &gt;= 0.25 )
          *quarters = (total / 0.25);
      if( total &gt;= 0.10 )
          *dimes = (total - (*quarters * 0.25)) / 0.10;
      if( total &gt;= 0.05 )
          *nickels = (total - (*quarters * 0.25) - (*dimes * 0.10)) / 
      0.05;
      if( total &gt;= 0.01 )
          *pennies = (total - (*quarters * 0.25) - (*dimes * 0.10) - 
      (*nickels * 0.05)) / 0.01 + .005;
   
      return 0;
      }
   
      void print(float total, int quarters, int dimes, int nickels, int 
      pennies)
      {
      printf(&quot;\nTOTAL VALUE ENTERED: $%.2f&quot;, total);
      printf(&quot;\n%3d quarters\n&quot;, quarters);
      printf(&quot;\n%3d dimes\n&quot;, dimes);
      printf(&quot;\n%3d nickels\n&quot;, nickels);
      printf(&quot;\n%3d pennies\n&quot;, pennies);
      }
  </code></pre>
  <p>The code should work for any coins entered by the user and should show the total at the end.</p>