P026.c (1310B)
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 /* WAP to input sum (p), rate of interest (r), time (t) and type of interest 8 ('s' for simple interest amd 'c' for compound interest). Calculate and display 9 the interest earned 10 si = (p * r * t) / 100 11 compoundInterest = p * ((1 + r / 100)^t - 1) 12 */ 13 14 #include <stdio.h> 15 #include <math.h> 16 #include <ctype.h> 17 int main() 18 { 19 double principalAmount, rateOfInterest, timePeriod, simpleInterest, compoundInterest; 20 char mode; 21 printf("Enter the principle amount, Rate of interest, Time : "); 22 scanf("%lf %lf %lf", &principalAmount, &rateOfInterest, &timePeriod); 23 printf("\nEnter the mode ('s' : simple interest, 'c' : compound interest) : "); 24 scanf(" %c", &mode); 25 mode = tolower(mode); 26 switch (mode) 27 { 28 case 's': 29 simpleInterest = (principalAmount * rateOfInterest * timePeriod) / 100; 30 printf("\nSimple Interest : %g", simpleInterest); 31 break; 32 case 'c': 33 compoundInterest = principalAmount * (pow((1 + rateOfInterest / 100), timePeriod) - 1); 34 printf("\nCompound Interest : %g", compoundInterest); 35 break; 36 default: 37 printf("\nInvalid Input"); 38 return 1; 39 } 40 return 0; 41 }