Simple interest is the interest calculated on the original principal amount for a given rate and time period. In C++, it can be calculated using a simple arithmetic formula and stored in a variable.
- Uses the principal amount, rate of interest, and time period to calculate interest.
- The calculated interest is stored in a variable and can be displayed using std::cout.
Illustration
Input: P = 10000, R = 5, T = 5
Output: Simple Interest = 2500Input: P = 3000, R = 7, T = 1
Output: Simple Interest = 210
Formula
The formula to calculate simple interest is:
\text{Simple Interest} = \frac{P \times T \times R}{100}
Where:
- P is the principal amount.
- T is the time period.
- R is the rate of interest.
Approach
- Initialize variables for the principal amount, rate of interest, and time period.
- Calculate simple interest using the formula.
- Store the result in another variable.
- Print the calculated simple interest.
Example: Program to find Simple Interest.
#include<iostream>
using namespace std;
// Driver code
int main()
{
// We can change values here for
// different inputs
float P = 1, R = 1, T = 1;
// Calculate simple interest
float SI = (P * T * R) / 100;
// Print the resultant value of SI
cout << "Simple Interest = " << SI;
return 0;
}
Output
Simple Interest = 0.01
Explanation: In this example, the principal amount, rate of interest, and time period are initialized using float variables. The simple interest is calculated using the formula (P * T * R) / 100 and stored in the simpleInterest variable before being displayed using std::cout.