复利 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

更新日期:30-07-2019

881 次浏览

开启您的 职业生涯

完成本课程以获得认证

开始
广告
© . All rights reserved.