main()
{
int year, period ;
float amount, inrate, value ;
printf("Input amount, interest rate, and period\n\n") ;
scanf ("%f %f %d", &amount, &inrate, &period) ;
printf("\n") ;
year = 1 ;
while( year <= period )
{
value = amount + inrate * amount ;
printf("%2d Rs %8.2f\n", year, value) ;
amount = value ;
year = year + 1 ;
}
}
Output
Input amount, interest rate, and period
10000 0.14 5
1 Rs 11400.00
2 Rs 12996.00
3 Rs 14815.44
4 Rs 16889.60
5 Rs 19254.15
Input amount, interest rate, and period
20000 0.12 7
1 Rs 22400.00
2 Rs 25088.00
3 Rs 28098.56
4 Rs 31470.39
5 Rs 35246.84
6 Rs 39476.46
7 Rs 44213.63