C++ & Python Program to Calculate Compound Interest

Posted in

C++ & Python Program to Calculate Compound Interest

Vinay Khatri
Last updated on August 28, 2022

    Here in this program, we will calculate Compound Interest using the formula: CI = p(1+r/100) t Here CI = compound interest p= principal r= rate t= time

    C++ Program to Calculate Compound Interest

    #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 Program to Calculate Compound Interest

    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

    People are also reading:

    Leave a Comment on this Post

    0 Comments