Sunday 28 December 2014

Write a c++ program to find Simple Interest and Compound Interest.



#include<cmath>
#include<iostream>
using namespace std;
double simple(int p,float r,int t)
{
return (p*r*t)/100;
}
double amount(int p,float x,int y,float z)
{ x= 1+z/100;
return p*pow(x,y);
}
double compound(int c,int d) {
return c-d;
}
int main()
{ int p=0,t=0;
float r;
double s = simple(200,1.2,2);
double d = amount(200,1.2,2,2.4);
double ci = compound(d,p);
}


Things to learn :

include<cmath> is used in place of include<math.h>
include<cmath>h is used in gcc compiler (in linux)

pow() is an inbuilt function in c++ with syntax :
double pow (double base, double exponent);

No comments:

Post a Comment

SAY HELLO!!