/* ----------------------------------------  
   File   : compound.c
   Purpose: Compound interest calculation
   Note   : compile with: cc -lm
   Author : Lew Baxter
   Date   : 2010-09-08
   ---------------------------------------- */

#include <stdio.h>
#include <math.h>

main()
{
   double principal, rate, amount;
   int time;

   /* ask user for principal, rate and number of years */

   printf(">>> COMPOUND INTEREST CALCULATOR <<<\n");

   printf("Principal?     $");   scanf("%f", &principal);
   printf("Rate [%%]?      ");   scanf("%f", &rate);
   printf("Time [years]?  ");    scanf("%d", &time);

   /* calculate and print amount */

   amount = principal * pow( ( 1 + rate/100.0), time );

   printf("Amount will be $%.2f\n", amount);
}