Thursday, 1 August 2013

Chapter 3 solutions Problem [E][i]

Question-When interest compounds qtimes per year at an annual rate of 
r % for nyears, the principle p compounds to an amount a as per
the following formula 
a = p ( 1 + r / q ) ^nq
Write a program to read 10 sets of p,r, n& q and calculate 
the corresponding as. 
Solution-

#include<stdio.h>
#include<math.h>
int main()
{
int p,n,i,q;
float a,r;
printf("Enter p,n,r,q\n");
for(i=1;i<=10;i++)
{
scanf("%d%d%f%d",&p,&n,&r,&q);
 a=pow(p*(1+r/q),n*q);
printf("P=%d ||N=%d ||R=%f ||Q=%d|| a=%f\n",p,n,r,q,a);
}
return 0;
}

1 comment:

  1. Here's A mistake in this formula in the program,
    In program you have applied the power at whole formula,
    in real: p * pow ( (1+ r/q), n*q);

    ReplyDelete