/* prototypes */
void printline (char c);
voidvalue (float, float, int);
main( )
{
float principal, inrate;
int period;
printf("Enter principal amount, interest");
printf(" rate, and period \n");
scanf("%f %f %d",&principal, &inrate, &period);
printline('Z');
value(principal,inrate,period);
printline('C');
}
void printline(char ch)
{
int i ;
for(i=1; i <= 52; i++)
printf("%c",ch);
printf("\n");
}
voidvalue(float p, float r, int n)
{
int year ;
float sum ;
sum = p ;
year = 1;
while(year <= n)
{
sum = sum * (1+r);
year = year +1;
}
printf("%f\t%f\t%d\t%f\n",p,r,n,sum);
}
Output
Enter principal amount, interest rate, and period
5000 0.12 5
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
5000.000000 0.120000 5 8811.708984
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC