Thursday, January 20, 2011

Constants, Variables and Data Types

Program to calculate the value of money at the end of each year of investement, assuming an interest rate and prints the year, and the corresponding amount in two columns.Using scanf function.
#include<stdio.h>
void 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 ;
}
getch();
}

No comments:

Post a Comment