fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. // (1)
  7. // input: balance, r, holding_years
  8. // output: balance for each year
  9. int balance = 100, r = 10, holding_years = 10;
  10. for (int i = 1; i <= holding_years; i++) {
  11. balance *= (1 + r / 100.0);
  12. cout << i << ": " << balance << endl;
  13. }
  14.  
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5268KB
stdin
Standard input is empty
stdout
1: 110
2: 121
3: 133
4: 146
5: 160
6: 176
7: 193
8: 212
9: 233
10: 256