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 a = p ( 1 + r / q )^nq Write a program to read p, r, n & q and calculate the corresponding as
/*
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
a = p ( 1 + r / q )^nq
Write a program to read p, r, n & q and calculate the corresponding as.
*/
#include<stdio.h>
int main()
{
int p, n, r, i, s;
float q,a=1.0;
printf("Enter value of p n r q\n");
scanf("%d%d%d%f", &p,&n,&r,&q);
s=n*q;
for ( i = 1; i <= s; i++)
{
a=a*p*(1+r/q);
}
printf("your value is %f", a);
return 0;
}
Comments
Post a Comment