# C++ Program to Calculate Simple Interest

Howdy readers, today you will learn how to write a C++ program to calculate simple interest.

Simple interest is a method to calculate the amount of interest charged on a sum at a given rate and for a given period of time.

Simple interest is calculated using the following formula: S.I. = P x R X T, the rate of interest is in percentage and is written to be as r /100. So, the formula becomes:

• S.I. = (P x R x T) / 100

Where,

• P is the principal amount which is initially borrowed from the bank or investor.
• R is the rate of interest at which the principal amount is given to someone.
• T is the duration (Time period) for which the principal amount is given to someone.

The below program prompts the user to enter the principal amount, rate of interest and the total number of years. Then, it uses the above formula to calculate simple interest.

So, without any delay, let’s begin this tutorial.

## C++ Program to Calculate Simple Interest

C++ Program

```// C++ Program to Calculate Simple Interest
#include <iostream>
using namespace std;

int main(){
float p, t, r;
float SI;

// Taking input
cout << "Enter the principal amount: ";
cin >> p;
cout << "Enter the rate of interest: ";
cin >> r;
cout << "Enter the time period[in Years]: ";
cin >> t;

// Compute simple interest
SI = (p * r * t) / 100;

// Print Result
cout << "Simple interest is: " << SI << endl;

return 0;
}
```

Output

```Enter the principal amount: 50000
Enter the rate of interest: 4
Enter the time period[in Years]: 3
Simple interest is: 6000
```

Explanation

```    float p, t, r;
float SI;
```

In the above program, we have declared four float data type variables named `p`, `t`, `r`, and `SI`.

```    // Taking input
cout << "Enter the principal amount: ";
cin >> p;
cout << "Enter the rate of interest: ";
cin >> r;
cout << "Enter the time period[in Years]: ";
cin >> t;
```

The program prompts the user to enter the principal amount, rate of interest and time period. The entered values get stored in the `p`, `r`, and `t` named variables respectively.

```    // Compute simple interest
SI = (p * r * t) / 100;
```

Now, simple interest is calculated using the formula: S.I. = (P x R x T) / 100. The simple interest obtained gets stored in the `SI` named variable.

```    cout << "Simple interest is: " << SI << endl;
```

Finally, the simple interest is printed on the screen using the cout statement.

## Conclusion

Today you learned how to write a C++ program to calculate simple interest.

This is one of the simplest programs to calculate simple interest using the C++ Programming language.

If you have any different logic than this program, then comment down your code in the comment section. So, the other users can get multiple perspectives to write this program.

If you find any difficulty understanding this program, then comment down your queries in the comment section.