Write a program to input sum, rate, time and type of Interest ('S' for Simple
Interest and 'C' for Compound Interest). Calculate and display the sum and the
interest earned.
The Simple Interest (SI) and Compound Interest (CI) of a sum (P) for a given
time (T) and rate (R) can be calculated as:
(a) SI = (p * r * t) / 100
(b) CI = P * ((1 + (R / 100))T - 1)
Note: Display the menu. Accept the user’s choice and use switch case
Answers
Explanation:
Simple Interest and Compound Interest are the ways of calculating the interest charge on the principal loan amount.
Simple Interest is calculated on the principal amount, using the formula:
S.I = (P * R * T) / 100 where P = Principal R = Rate and T = Time.
Compound Interest is calculated on the principal amount and the interest that accumulates on it in every period, using the formula:
CI = P(1 + r / n)nt where P = Principal, R = Rate,n = number of compounding periods per unit and T = Time
Let’s implement the C Program to find Simple Interest and Compound Interest.
#include<stdio.h>
int main()
{ int c,t,r,p,SI=0,CI=0;
printf("Input 1 for Simple Interest\nInput 2 for Compound Interest\n");
scanf("%d",&c);
switch(c)
{
case 1:
printf("Input Time\n");
scanf("%d",&t);
printf("Input Principal\n");
scanf("%d",&p);
printf("Input Rate\n");
scanf("%d",&r);
SI= (p*r*t)/100;
printf("Simple Interest=%d",SI);
break;
case 2:
printf("Input Time\n");
scanf("%d",&t);
printf("Input Principal\n");
scanf("%d",&p);
printf("Input Rate\n");
scanf("%d",&r);
CI=p* 1+r/100*t-1;
printf("Compound Interest=%d",CI);
break;
}
return 0;
}
Hope it is helpful
Sahil