Monday 14 January 2013

Let Us C Chapter 3 problem No: E-l


//Program to calculate amount  of compound interest
//Formula for compound Interest: a = p ( 1 + r / q )^nq

#include<iostream>
#include<math.h>

using namespace std;

int main(void)
{
    float r,a1,a2,p,q,n,t1,t2,i;


    for(i=0;i<10;i++)
    {
        cout<<"Enter details for set "<<i+1;
        cout<<endl;
        cout<<"Enter the Principle(p):  ";
        cin>>p;
        cout<<"Enter the rate of interest(r):  ";
        cin>>r;
        cout<<"Enter number of years(n):  ";
        cin>>n;
        cout<<"Enter the number of periods per year (q):  ";
        cin>>q;

        t1= (1+(r/q));
        t2=n*q;
        a1=pow(t1,t2);
        a2=(p*a1);

        cout<<a2;
        cout<<endl<<endl;
    }
}

No comments:

Post a Comment

Comments please: