C语言计算单利程序

如何编写C语言计算单利的程序,并附带一个例子。在开始示例之前,我将向您展示计算背后的公式。

单利 = (本金*利率*年数) / 100

程序允许用户输入本金、利率和年数。利用上述公式,我们将在程序中计算这些值的单利。

#include<stdio.h>
 
int main() 
{
   float PAmount, ROI, Time_Period, si;
 
   printf("\nPlease enter the Principal Amount : \n");
   scanf("%f", &PAmount);
 
   printf("Please Enter Rate Of Interest : \n");
   scanf("%f", &ROI);
 
   printf("Please Enter the Time Period in Years : \n");
   scanf("%f", &Time_Period);
 
   si = (PAmount * ROI * Time_Period) / 100;
   printf("\nSimple Interest for Principal Amount %.2f is = %.2f", PAmount, si);
 
   return 0;
}
Program to Calculate Simple Interest

评论已关闭。