luc036.c (1377B)
1 /* When interest compounds q times per year at an annual rate of 2 r % for n years, the principle p compounds to an amount a as per 3 the following formula 4 a = p (1 + r / q) ^ nq 5 Write a program to read 10 sets of p, r, n & q and calculate the 6 corresponding as' */ 7 /* Let Us C, Chap- 6, Page - 106, Qn No.: B(c) */ 8 9 // DEVELOPMENT STATUS: This implementation is currently untested. 10 // Please report any functional defects or errors by submitting a GitHub issue "https://github.com/notamitgamer/bsc/issues" with the updated code. 11 12 #include <stdio.h> 13 #include <math.h> 14 int main() 15 { 16 double interest, principalAmount, interestRate, timeInYears, compoundFactor, totalAmount; 17 int index; 18 for (index = 1; index <= 10; index++) 19 { 20 printf("Enter Principle amount : "); 21 scanf("%lf", &principalAmount); 22 printf("Enter Rate of Interest : "); 23 scanf("%lf", &interestRate); 24 interestRate *= 0.01; 25 printf("Enter the Time (Years) : "); 26 scanf("%lf", &timeInYears); 27 printf("Compound count in one year : "); 28 scanf("%lf", &compoundFactor); 29 totalAmount = (principalAmount * pow((1 + interestRate / compoundFactor), (timeInYears * compoundFactor))); 30 interest = totalAmount - principalAmount; 31 printf("\nInterest : %.2f\nTotal Amount : %.2f\n\n", interest, totalAmount); 32 } 33 return 0; 34 }