In this section, you will learn how to read the principle, rate and time from the user and write a C program to calculate simple interest and the total amount.
SIMPLE INTERSET = (P*R*T)/100
(Here, P = Principal Amount, R= Rate and T= Time)
TOTAL AMOUNT = P + Simple Interest
Logic :
- Take input principle amount, time and rate in some variable.
- Then take input time in some variable.
- Then take input rate in some variable.
- Find simple interest using formula mentioned above.
- Finally, print the value of Simple Interest.
- Then, to find the Total amount add principal amount to the simple interest.
Program to calculate simple interest and total amount
/* C-Program: Calculate Simple Interest and total amount */
#include <stdio.h>
int main()
{
long int p;
int t;
float r, si, tamt;
printf("Enter the Principal Amount: ");
scanf("%ld", &p);
printf("Enter the Time (or period): ");
scanf("%d", &t);
printf("Enter the Rate of Interest: ");
scanf("%f", &r);
si = (p*t*r)/100;
tamt = p + si;
printf("\nPrincipal Amount = %ld", p);
printf("\nTime = %d", t);
printf("\nRate of interest =%.2f", r);
printf("\nSimple Interest = %.2f", si);
printf("\nTotal Amount = %.2f", tamt);
return 0;
}
Output :-
Enter the Principal Amount: 11200 Enter the Time (or period): 3 Enter the Rate of Interest: 10.5 Principal Amount = 11200 Time = 3 Rate of interest =10.50 Simple Interest = 3528.00 Total Amount = 14728.00
