Write a program to calculate simple interest using c++
Answers
Simple Interest in C++
We are tasked with making a Simple Interest Calculation Program in C++.
The formula for Simple Interest () is given by:
where:
P = Principal
R = Rate of Interest
N = Number of Years (or Time)
So, from a Programming perspective, we must first take user input for the values of P, R and N. We will keep their data types as double to account for fractional values as well.
After that we can calculate the Simple Interest using the formula and display it to the user.
C++ Code:
#include <iostream>
using namespace std;
int main()
{
double P,R,N;
cout << "Simple Interest Calculator" << endl;
cout << "Enter Principal (P): ";
cin >> P;
cout << "Enter Rate of Interest (R): ";
cin >> R;
cout << "Enter Number of Years (N): ";
cin >> N;
double I = P*R*N/100;
cout << "The Simple Interest is I = " << I << endl;
return 0;
}
Screenshots of Code and a Runtime Example are attached.