我正在尝试编写一个程序,在dev c++中打印简单兴趣和复合兴趣,但它没有打印正确的复合兴趣,谁知道为什么?这是我的代码:
#include<stdio.h>
#include<math.h>
int main()
{
int p,r,t,si,ci;
printf("enter the principle:");
scanf("%d",&p);
printf("enter the rate:");
scanf("%d",&r);
printf("enter the time:");
scanf("%d",&t);
si=p*r*t/100;
ci=p*pow((1+(r/100)),t);
printf("simple interest:%d",si);
printf("\ncompound interest:%d",ci);
int a=getch();
return 0;
}发布于 2021-12-12 09:32:38
你给出的是int而不是浮点。
#include<stdio.h>
#include<math.h>
int main(){
float p,r,t,si,ci;
printf("enter the principle:");
scanf("%d",&p);
printf("enter the rate:");
scanf("%d",&r);
printf("enter the time:");
scanf("%d",&t);
si=p*r*t/100;
ci=p*pow((1+(r/100)),t);
printf("simple interest:%d",si);
printf("\ncompound interest:%d",ci);
int a=getch();
return 0;
}https://stackoverflow.com/questions/70322098
复制相似问题