Saturday, January 30, 2010

CHAP 3[E]L Calculating total amount after interest

When interest compounds q times per year at an annual rate of r % for n years, the principle p compounds to an amount a as per the following formula







Write a program to read 10 sets of p, r, n & q and calculate the corresponding as.


void main()
{
float a,p,r,q,n,x,y,z,w;


a=1;

for(z=1;z<=2;z++)
{
printf("\nEnter the values of p,r,n &q");
scanf("%f%f%f%f",&p,&r,&n,&q);
x=n*q;

for(y=1,a=1;y<=x;y++)
{
a=a*(1+r/q);
}

w=a*p;
printf("\nThe value of a is %f",w);
}

}

No comments:

Post a Comment