/*--------INVERSTMENT PROBLEM -------*/ #define PERIOD 10 #define PRINCIPAL 5000.00 main() { int year; float amount, value, inrate; amount=PRINCIPAL; inrate=0.11; year=0; while(year <= PERIOD) { print_r("%2d %8.2f\n",year, amount); value = amount + inrate * amount; year = year + 1; amount = value; } }
Output
0 | 5000.00 |
1 | 5550.00 |
2 | 6160.50 |
3 | 6838.15 |
4 | 7590.35 |
5 | 8425.29 |
6 | 9352.07 |
7 | 10380.00 |
8 | 11522.69 |
9 | 12790.00 |
10 | 14197.11 |