Thursday, January 20, 2011

Overview of C

This program calculates the value of money at end of each yaer of investment,
assuming an interest rate of 11 percent and prints the year, and the corresponding amount,
int two columns.

# include< stdio.h > 
#define PERIOD 10
#define PRINCIPAL 5000.00
void main()
{
int year;
float amount, value, inrate;
amount = PRINCIPAL;
inrate = 0.11;
year = 0;

while(year <= PERIOD)
{
 printf("%2d %8.2f\n",year, amount);
value = amount + inrate * amount;
year = year + 1;
amount = value;
}
getch();
}

No comments:

Post a Comment