C++ Program to Calculate simple interest


January 31, 2023, Learn eTutorial
1255

This is a program in C++ to calculate and print the simple interest based on the data entered by the user at run-time.

What is called simple interest?

Simple interest is the interest that we have to pay for a principal amount for a time period with a certain rate of interest. Simple interest is a straightforward technique for calculating interest in money.

How does simple interest calculate?

Simple Interest is calculated using the following formula: SI = P × R × T, where P = Principal, R = Rate of Interest, and T = Time period. Here, the rate given in percentage (r%) is written as r/100. And the principal is the sum of money that remains constant every year in the case of simple interest.
The formula to find simple interest is:
SI = (P*R*T)/100

C++ program to calculate simple interest

Here the value of P, R, and T have to be entered by the user at run-time.
Ask the user to enter the principal amount and read the value into the variable p; Ask the user to enter the rate of interest and get the value to the variable r and ask the user to enter the time period and get the value to the variable t; calculate the simple interest by using the formula    si = (p*r*t)/100;
Display the value on the variable si.

Algorithm

Step 1: Call the header file iostream.

Step 2: Use the namespace std.

Step 3: Open the main function; int main().

Step 4: Declare  float type variables p, r, t, si;

Step 5: Ask the user to enter the principal amount

Step 6: Get the value to the variable p;

Step 7: Ask the user to enter the rate of interest;

Step 8: Get the value to the variable r;

Step 9: Ask the user to enter the time period;

Step 10: Get the value to the variable t;

Step 11: Calculate the simple interest by using the formula si = (p*r*t)/100;

Step 12: Display the result

Step 13: exit
 

C++ Source Code

                                          #include<iostream>

using namespace std;
int main()
{
   float p, r, t, si;
   cout<<"Enter Principle Amount: ";
   cin>>p;
   cout<<"Enter Rate of Interest: ";
   cin>>r;
   cout<<"Enter Time Period: ";
   cin>>t;
   si = (p*r*t)/100;
   cout<<"\nSimple Interest Amount: "<<si;
   cout<<endl;
   return 0;
}
                                      

OUTPUT

Enter Principle Amount: 256000
Enter Rate of Interest: 8
Enter Time Period: 5
Simple Interest Amount: 102400