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