Calculate Simple Interest

Program to calculate simple interest

BeginnerTopic: Basic Programs
Back

C++ Calculate Simple Interest Program

This program helps you to learn the fundamental structure and syntax of C++ programming.

Try This Code
#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    float principal, rate, time, interest;
    
    cout << "Enter principal amount: ";
    cin >> principal;
    
    cout << "Enter rate of interest (per year): ";
    cin >> rate;
    
    cout << "Enter time (in years): ";
    cin >> time;
    
    // Simple Interest = (P * R * T) / 100
    interest = (principal * rate * time) / 100;
    
    cout << fixed << setprecision(2);
    cout << "Simple Interest = " << interest << endl;
    cout << "Total Amount = " << principal + interest << endl;
    
    return 0;
}
Output
Enter principal amount: 10000
Enter rate of interest (per year): 5
Enter time (in years): 2
Simple Interest = 1000.00
Total Amount = 11000.00

Understanding Calculate Simple Interest

Simple interest is calculated using the formula: SI = (P * R * T) / 100, where P is principal, R is rate, and T is time. This program reads these values, calculates the interest, and displays both the interest and total amount.

Note: To write and run C++ programs, you need to set up the local environment on your computer. Refer to the complete article Setting up C++ Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your C++ programs.

Table of Contents