"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Monday, April 26, 2010

Write a program to calculate simple interest and compound interest

#include<iostream.h>
#include<conio.h>

#include<math.h>


void main()
{
double p, r, t, i, am;


cout<< " Enter principal, rate , time ?";
cin>> p >> r >> t;


// Calculate Simple interest
i = (p * r* t) / 100;
am = p + i;


cout<< "\n Principal Amt = Rs. " << p;
cout<< "\n Rate = " << r << "%" ;
cout << "\n Time = " << t << "yrs.";
cout<< "\n The Interest Amt = Rs. " << i ;
cout<< "\n The Total Amt = Rs. " << am;


// Calculate Compound interest
am = pow((p* ( 1 + (r/100)), t);
i = am - p;


cout << "\n The Interest Amt = Rs. " << i;
cout<< "\n The Total Amt = Rs. " << am;


getch();
}

2 comments:

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.