【发布时间】:2020-03-29 15:26:40
【问题描述】:
#include <stdio.h>
int main() {
float initialPrice, discount, VAT, priceWithVAT, priceWithDiscount;
initialPrice = 13.26;
VAT = 0.20;
discount = 0.125;
priceWithVAT = initialPrice * (1.0 + VAT);
priceWithDiscount = priceWithVAT * (1.0 - discount);
printf("Initial Price %10.2f\n", initialPrice);
printf(" + VAT @ %4.1f%% %10.2f\n", VAT * 100, priceWithVAT);
printf(" - discount @ %4.1f%%%10.2f\n", discount * 100, priceWithDiscount);
return 0;
}
我是 C 编程新手,我被要求修改上述程序,以便在计算之前使用 scanf 读取初始价格。
我需要做什么?
谢谢
【问题讨论】:
-
嗯...使用
scanf。 -
James Barry,您在使用
scanf()编码时遇到的具体问题是什么? -
Eraklon,谢谢你的明智之言。在您让我走上启蒙之路之前,我还不清楚这些。
-
这能回答你的问题吗? Reading float using scanf in c
标签: c