C++ Program to Calculate Simple Interest

In this post, we will learn how to calculate simple interest using C++ Programming language.

Simple interest is a method of calculating the interest amount for some principal amount. 

The formula for calculating simple interest is (P x R x T) / 100, where P is the principal amount, R is the rate of interest and T is the time period.

We will be using the same formula in our program to compute simple interest.

So, without further ado, let’s begin this tutorial.

C++ Program to Calculate Simple Interest

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

int main(){
    int p, t, r, SI;
    
    // Asking for input
    cout << "Enter the principal amount: ";
    cin >> p;
    cout << "Enter the time period(in years): ";
    cin >> t;
    cout << "Enter the rate of interest: ";
    cin >> r;
    
    // Calculating simple interest
    SI = (p*r*t) / 100;
    
    // Displaying output
    cout << "Simple Interest: " << SI << endl;
    return 0;
}

Output

Enter the principal amount: 3000
Enter the time period(in years): 2
Enter the rate of interest: 5
Simple Interest: 300

How Does This Program Work ?

    int p, t, r, SI;

In this program, we have declared some int data type variables which will store the values of amount, time, rate and interest.

    // Asking for input
    cout << "Enter the principal amount: ";
    cin >> p;
    cout << "Enter the time period(in years): ";
    cin >> t;
    cout << "Enter the rate of interest: ";
    cin >> r;

Then, the user is asked to enter the value of principal amount, time period and rate of interest.

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

We calculate the simple interest using the formula (P x R X T) / 100.

    // Displaying output
    cout << "Simple Interest: " << SI << endl;

Finally, the simple interest calculated above is displayed to the screen using the cout statement.

Conclusion

I hope after going through this post, you understand how to calculate simple interest using C++ Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

Also Read:

Leave a Comment

Your email address will not be published. Required fields are marked *