-3
我剛剛開始學習C.因此,對於實踐我決定寫一個利率計算器,但由於某種原因,我的計算總是作爲0出來,我無法弄清楚。如果你可以請看看。利率計劃
#include <stdio.h>
main()
{
int time;
float principle, rate, total;
printf("What is your starting amount? ");
scanf(" %f", &principle);
printf("What is your interest rate? ");
scanf(" %f", &rate);
printf("How long do you want to save? ");
scanf(" %d", &time);
total = principle * rate * time;
printf("You will have earned an interest amount of $%d", total);
return 0;
}
'%d'期望'int',而不是'float'。 –
哦,杜,謝謝我很抱歉浪費你的時間。 –
[演示](http://ideone.com/fMnqhN) –