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