複利 C 程式?
本文將透過編寫一個 C 程式幫助大家瞭解如何獲取複利。邏輯很簡單。需要以下幾個引數 −
- P − 本金金額
- R − 利率
- T − 時長
複利公式如下:

示例
#include<stdio.h>
#include<math.h>
float compoundInterest(float P, float T, float R) {
return P*(pow(1+(R/100), T));
}
int main() {
float p, t, r;
printf("Enter Princple amount, rate of interest, and time: ");
scanf("%f%f%f", &p, &r, &t);
printf("Interest value: %f", compoundInterest(p, t, r));
}輸出
Enter Princple amount, rate of interest, and time: 5000 7.5 3 Interest value: 6211.485352
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP