/*Write a C++ program to input principal amount, rate of interest and time period. Calculate compound interest using while statement.
(Hint: Amount = P * (1 + R/100)T, Compound Interest = Amount - P)*/
#include<iostream.h>
#include<conio.h>
void main( )
{
float priamt,netamt,rate,ci;
int time,year;
clrscr();
cout<<"Enter the Principal amount, rate of interest and time:"<<endl;
cin>>priamt>>rate>>time;
netamt=priamt;
year = 1;
while(year<=time)
{
netamt = netamt*(1 + rate/100);
year ++;
}
ci = netamt - priamt;
cout<<"Compound Interest = "<<ci<<endl;
cout<<"Net Amount = "<<netamt<<endl;
getch( );
}

No comments: