Write a Program in C, C++ and in Python to Calculate Simple Interest

By | October 4, 2021

Here we have provided two programs that calculate the simple interest when the user provides the principal, rate, and time. so let’s write a Program to Calculate Simple Interest.

To calculate the simple interest, we have used this formula:

Program to Calculate Simple Interest

SI = (p*r*t) / 100

SI = Simple interest

p = principal

Vamware

r = rate

t = time in years

Vamware

C++

#include<iostream.h>
#include< conio.h>

void main()
{
clrscr();
float SI, p,r,t;
cout<<"Enter Principal: ";
cin>>p;
cout<<"Enter rate: ";
cin>>r;
cout<<"Enter Time: ";
cin>>t;
SI = (p*r*t)/100;
cout<<"The SI is:"<<SI;
getch();
}

Output:

Enter Principal: 30000
Enter rate: 2
Enter Time: 4
The SI is: 2400.0

 

Python 

p= float(input("Enter Principal: "))
r= float(input("Enter rate: "))
t= float(input("Enter Time: "))
SI = (p*r*t)/100
print("The SI is:",SI)

 

Output

Enter Principal: 30000
Enter rate: 2
Enter Time: 4
The SI is: 2400.0

People are also reading:

Leave a Reply

Your email address will not be published.