C++ Program to Calculate simple interest

Formula to calculate simple interest

C++ program to calculate simple interest has been shown here. Simple interest is the amount of interest which is calculated based on the initial principal, interest rate and time (in years). It is determined by using following formula:


$SI = {\Large \frac{p * r * t}{100}}$


Here $SI$ represents simple interest. Pricipal amount, annual interest rate and time have been represented by $p$, $r$ and $t$ respectively. As an example, let's assume $p = 1000$, $r = 5$ and $t = 2$ then by using above formula, we get the value of simple interst $SI = 100$.






1. C++ Program & output to calculate simple interest

Code has been copied
/***************************************
        alphabetacoder.com
 C++ program to compute simple interest
***************************************/

#include <iostream>

using namespace std;

int main(){
    //declare variables
    float p,r,t,si;
    
    //take input of principal, interest rate and time
    cout<<"Enter principal amount= ";
    cin>>p;
    cout<<"Enter interest rate= ";
    cin>>r;
    cout<<"Enter time= ";
    cin>>t;
    
    //calculate simple interest
    si=p*r*t/100;
    
    //print result
    cout<<"Simple interest= "<<si<<endl;
    return 0;
}

Output


Enter principal amount= 5000

Enter interest rate= 3.5

Enter time= 5

Simple interest= 875