Write C++ program to calculate compound Interest


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

Introduction

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


  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. float amount, rate, intrest, time, ci, a;
  9.  
  10. /*Reading amount, rate of intrest
  11.   and period in years from user
  12.   */
  13. cout<<"Type the amount: ";
  14. cin>>amount;
  15.  
  16. cout<<"Type the interest rate: ";
  17. cin>>rate;
  18.  
  19. cout<<"Type the period in years: ";
  20. cin>>time;
  21.  
  22. intrest = 1+(rate/100);
  23.  
  24. // ci=pow(intrest,time);
  25. ci = 1;
  26. for(a = 1; a <= time; a++)
  27. ci = ci * intrest;
  28.  
  29. ci = amount * ci - amount;
  30.  
  31. cout<<"Your compound interest is: " <<ci;
  32.  
  33. return 0;
  34. }
  35.  

Result

C++ language techstudy.org

     





Related Topics




Popular Posts