getrate.c (469B)
1 /* Esercizio 4.15 */ 2 3 #include <stdio.h> 4 #include <math.h> 5 6 int main() 7 { 8 double amount; 9 double principal = 1000.0; 10 double rate = 0.5; 11 int year, r; 12 13 for (r = 5; r <= 10 ; rate += 0.1, ++r) { 14 15 printf("\n%4s%21s [%d%%]\n", "Year", "Amount of deposit", r); 16 for (year = 1; year <= 10; year++) { 17 18 amount = principal * pow(1.0 + rate, year); 19 20 printf("%4d%21.2f\n", year, amount); 21 } 22 } 23 24 return 0; 25 } /* E0F main */ 26