title: Doubling a variable numerous times, and adding all iterations of the variable together
body: <p>EDITED FOR CLARITY'S SAKE. I APOLOGIZE FOR THE CONFUSION :3</p>
  
  <p>Okay, so I'm following an online CS class, and we're supposed to write a program, in C, that will tell you how much money you'd have if you had a penny at the beginning of the month and doubled it every day.</p>
  
  <p>Each day you would get double what you had yesterday PLUS everything from the previous days.</p>
  
  <p>Example: You start with .01 and what to calculate a running total by day 3. So the first day is .01, second day is .02, third day is .04. On day 3 you would have 0.01+0.02+0.04 (.09).</p>
  
  <p>The program intends to calculate this process over the duration of any given month (28 - 31 days).</p>
  
  <p>I'm having a really hard time trying to implement this. I've got it doubling it, but I'm not sure how to the previously-calculated days together.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  int main(void) {
  
      /*days represents total days in months*/
      /*pens represents the number of pennies on the first day*/
  
      long long days;
      long long pens;
  
      do {
        printf("Enter the number of days in the month: ");
        scanf("%llu", &amp;days);
      } while(days &lt; 28 || days &gt; 31);    
  
      printf("Enter the initial number of pennies: ");
      scanf("%llu", &amp;pens);
  
      for (int i=0; i&lt;= days-1; i++) {
        pens += pow(2,i);
        printf("You'll have $%llu\n", pens);
      }
  }
  </code></pre>
  
  <p>edit2: Okay, so I think I fixed it thanks to all your awesome advice. I changed the last part to:</p>
  
  <pre><code>for (int i=0; i&lt;= days-1; i++)
          {
              pens = pens + (pens * 2);
  
          }
          total = pens / 100;
          printf("You'll have $%.2f\n", total);
  
      } 
  </code></pre>
  
  <p>Though there is still a slight issue with the output (which, I'm thinking, is due to the data type I'm using?)
  It prints out:</p>
  
  <p>You'll have $0.00
  You'll have $0.00
  You'll have $0.00
  You'll have $0.00
  You'll have $2.00
  You'll have $7.00
  You'll have $21.00
  You'll have $65.00
  You'll have $196.00
  You'll have $590.00
  You'll have $1771.00
  You'll have $5314.00
  You'll have $15943.00
  You'll have $47829.00
  You'll have $143489.00
  You'll have $430467.00
  You'll have $1291401.00
  You'll have $3874204.00</p>
  
  <p>etc.</p>
  
  <p>Pretty good, but I'm betting it's not that accurate since the first few iterations are 0.00.</p>