title: Result of previous line (C programming)
body: <p>I'm taking a C programming class and I'm doing practice questions in the book. One of the questions is:</p>
  <blockquote>
  <p>Write a program that asks the user to enter a U.S. dollar amount and then shows how to pay that amount using the smallest number of $20, $10, $5, %1 bills:</p>
  </blockquote>
  <p>The sample is as follows:something right away that I may have overlooked when trying my code.</p>
  <blockquote>
  <p>Enter a dollar amount: 93 (user inputted)</p>
  <p>$20 bills: 4<br />
  $10 bills: 1<br />
  $5 bills: 0<br />
  $1 bills: 3</p>
  </blockquote>
  <p>What I have so far is:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main (void) 
  {
   int cash;
   
   printf(&quot;Enter a dollar amount: &quot;);
   scanf(&quot;%d&quot;, &amp;cash);
       
   printf(&quot;$20 bills = %d\n&quot;, cash / 20);
   printf(&quot;$10 bills = %d\n&quot;, cash / 10);
   printf(&quot;$5 bills = %d\n&quot;, cash / 5);
   printf(&quot;$1 bills = %d\n&quot;, cash / 1);
   return 0;
  }
  </code></pre>
  <p>The problem is, the book suggests dividing the input number (93) by 20, and since I'm using <code>int</code> instead of <code>float</code>, that leaves <code>4</code> instead of <code>4.65</code>. Then it suggests subtracting the result of that times <code>20</code>, from <code>93</code>, leaving <code>13</code>, and repeating that for each one. So it would be:</p>
  <pre><code>93/20=4
  13/10=1
  3/1=3
  </code></pre>
  <p>How can I get the <code>printf(&quot;$10 bills = %d\n&quot;, cash / 10);</code> line to recognize the value left by the previous line, <code>printf(&quot;$20 bills = %d\n&quot;, cash / 20);</code>? I had originally tried to put most of it on the 20 bill line, like <code>cash / 20 * 20</code>, but it just displayed <code>80</code> on that line instead of the next line.</p>