Here in this program, we will calculate the compound interest using the formula:
CI = p(1+r/100)t
Here
CI = compound interest
p= principal
r= rate
t= time
C++:
#include<iostream.h> #include< conio.h> #include<math.h> void main() { clrscr(); float CI,p,r,t; cout<<"Enter the Principal value: "; cin>>p; cout<<"Enter the rate value: "; cin>>r; cout<<"Enter the time: "; cin>>t; CI = p*pow((1+(r/100)),t); cout<<"The compound interest is: "<<CI; getch(); }
Output:
Enter the Principal value: 30000 Enter the rate value: 20 Enter the time: 10 The compound interest is: 185752.0926719999
Python
p = float(input("Enter the Principal value: ")) r= float(input("Enter the rate value: ")) t= float(input("Enter the time: ")) CI =p*((1+(r/100))**t) print("The compound interest is:",CI)
Output:
Enter the Principal value: 20000 Enter the rate value: 3 Enter the time: 4 The compound interest is: 22510.1762