25. Program that inputs principal amount, rate of interest and total time. It calculates the compound interest and displays it.

Chapter 4: 

Input And Output

Programming Exercise

Problem # 25:

Write a program that inputs principal amount, rate of interest and total time. It
calculates the compound interest and displays it.

Solution:

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
    float p, r, t, ci;         //prinipal ammount, rate of interest, time, compound interest;
    cout<<"Enter principal amount";
    cin>>p;
    cout<<"Enter rate of interest";
    cin>>r;
    cout<<"Enter total time";
    cin>>t;
    ci=p*pow(1+(r/100),t);
    cout<<"Compound Interest: "<<ci<<endl;
    getch();
    return 0;
}

Let me know in the comment section if you have any question.

Previous Post:
24. Program that inputs two times in hh:mm:ss format, adds both times and display the total time.

Comments