Find Simple Interest using C++



Write a Program in C++ to find Simple
Interest.





#include <iostream.h>


#include <conio.h>





 class
SI


  {


  
public:


   
double p,t,r;


   
void interest(double,double,double);


  };





  void
SI :: interest(double a, double b, double c)


   {


   
double i,sum;


   
p=a;


   
t=b;


   
r=c;


   
i=(p*t*r)/100;


   
sum=p+i;


   
cout<<"\nThe Interest is: "<<i;


   
cout<<"\nThe Sum is: "<<sum;


   
getch();


   }





 int
main()


  {


 
double principal,time,rate;


 
clrscr();


 
cout<<"Principal: ";


 
cin>>principal;


 
cout<<"Time: ";


 
cin>>time;


 
cout<<"Rate: ";


 
cin>>rate;


  SI
ob;





 
ob.interest(principal,time,rate);





 
return 0;


  }





Output:


Principal: 5000


Time:10


Rate: 10


The Interest is: 5000


The Sum is: 10000







Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C