bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

APC-PRAC-013.c (1053B)


      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 /* Write a program to input sum(p), rate of interest(r), time(t) and type of interest
      8 ('s' for simple interes, 'c' for compound interest), then calculate and display the earned interest */
      9 
     10 #include <stdio.h>
     11 #include <math.h>
     12 #include <ctype.h>
     13 
     14 int main()
     15 {
     16     double p, t, r, si, ci;
     17     char mode;
     18     printf("Enter the Principle, Time (Year) and the Rate of Interest : ");
     19     scanf("%lf %lf %lf", &p, &t, &r);
     20     printf("Enter the mode of calculation ('s' for simple interest, 'c' for compound interest) : ");
     21     scanf(" %c", &mode);
     22     mode = tolower(mode);
     23     switch (mode)
     24     {
     25     case 's':
     26         si = (p * t * r) / 100;
     27         printf("\nSimple Interest : %g", si);
     28         return 0;
     29     case 'c':
     30         ci = (p * pow(1 + (r / 100), t)) - p;
     31         printf("\nCompound Interest : %g", ci);
     32         return 0;
     33     default:
     34         printf("\nYou entered a wrong choice.");
     35         return 1;
     36     }
     37 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror