This article is from solution of Let Us C by Yashwant Kanetkar. I also posted many another articles regarding solutions of Let Us C. If you have any problem regarding solution then give comment, I will surely reply your question.
Q. When interest compounds q times per year at an annual rate of r% for n years, the principal p compounds to an amount a as per the following formula
a = p(1 + r/q)nq
Write a program to read 10 seats of p, r, n & q and calculate the corresponding a.Ans.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float p, r, n, q, a;
int i;
for(i=1;i<=10;i++)
{
printf("\nenter values of p, r, n, q ");
scanf("%f%f%f%f",&p,&r,&n,&q);
a=p*pow((1+(r/q)),n*q);
printf("\nValue of a is %f\n",a);
}
getch();
}