Q:

Write C++ program to calculate compound Interest

0

Write C++ program to calculate compound Interest

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
#include <math.h>
 
using namespace std;
 
int main()
{
    float amount, rate, intrest, time, ci, a;
 
    /*Reading amount, rate of intrest
       and period in years from user
     */
     cout<<"Type the amount: ";
     cin>>amount;
 
     cout<<"Type the interest rate: ";
     cin>>rate;
 
     cout<<"Type the period in years: ";
     cin>>time;
 
     intrest = 1+(rate/100);
 
     // ci=pow(intrest,time);
     ci = 1;
     for(a = 1; a <= time; a++)
        ci = ci * intrest;
 
     ci = amount * ci - amount;
 
     cout<<"Your compound interest is: " <<ci;
 
    return 0;
}

Result:

Type the amount: 5000 

Type the interest rate: 10

Type the period in years: 1

Your compound interest is: 500

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write C++ program to check whether a number is Pri... >>
<< Write C++ program to check whether a number is Arm...