bsc

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

root / semester_1 / tuition-c / APC-PRAC-013.c

APC-PRAC-013.c (917B)


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