/* * Interest rate program revised to use "for" rather than "while". */ #include #include #define PRINCIPAL 5000.00 /* start with $5000 */ #define INTRATE 0.06 /* interest rate of 6% */ #define PERIOD 7 /* over 7-year period */ int main() { double balance; /* balance at year's end */ int year; /* year of period */ printf("Interest Rate: %7.2f%%\n", INTRATE * 100); printf("Starting Balance: $%7.2f\n\n", PRINCIPAL); printf("Period: %7i years\n\n", PERIOD); printf("Year Balance\n"); balance = PRINCIPAL; for (year = 1; year <= PERIOD; year = year + 1) { balance = balance + balance * INTRATE; printf("%4i $ %7.2f\n", year, balance); } return EXIT_SUCCESS; /* assume program worked! */ }