Program to calculate the sample interest. It inputs principal amount, rate of interest and the number of years and displays the simple interest.

Topic:

Standard Input in C++

Problem:

Write a program to calculate the sample interest. It inputs principal amount, rate of interest and the number of years and displays the simple interest.

Solution:

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
int main ()
{
 float i,p,r,t;
cout<<"enter principal amount:";
cin>>p;
cout<<endl<<"enter rate of interest:";
cin>>r;
cout<<endl<<"enter no. of years:";
cin>>t;
i=p*(r/100)*t;
cout<<"interest is:"<<i<<endl;
getch();
}

Output:





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

Previous Post:

Next Post: