ในบทช่วยสอนนี้ เราจะพูดถึงโปรแกรมเพื่อค้นหาดอกเบี้ยทบต้น
ดอกเบี้ยทบต้นคือดอกเบี้ยโดยการบวกดอกเบี้ยปัจจุบันเข้ากับเงินต้นแล้วคำนวณดอกเบี้ยจากจำนวนเงินที่อัพเดต
ตัวอย่าง
#include <bits/stdc++.h>
using namespace std;
int main(){
double principle = 10000, rate = 10.25, time = 5;
//calculating compound interest
double CI = principle * (pow((1 + rate / 100), time));
cout << "Compound interest is " << CI;
return 0;
} ผลลัพธ์
Compound interest is 16288.9