Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. /* Programming Exercise 6-17 */
  2.  
  3. // Chuckie Lucky won a million dollars (after taxes), which he places in an account that
  4. // earns 8% a year. On the last day of each year, Chuckie withdraws $100,000. Write a
  5. // program that finds out how many years it takes for Chuckie to empty his account.
  6.  
  7. #include <stdio.h>
  8. int main(void)
  9. {
  10.  
  11. float s = 1000000.0f;
  12. int year;
  13.  
  14. for (year=0; s > 0; year++)
  15. {
  16. s -= 100000.0f;
  17. printf("Balance: %.1f\n", year, s);
  18. s += (s*1.08f);
  19. printf("Balance: %.1f\n", year, s);
  20. }
  21.  
  22. printf("Bankrupt in %2d years with $ %.1f left \n", year, s);
  23.  
  24.  
  25.  
  26. getchar();
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement