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

Posted in

Vinay Khatri
Last updated on June 9, 2022

    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 r = rate t = time in years 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 Comment on this Post

    0 Comments