编写一个 C 程序,输入美元金额,然后添加 18% 的税金来显示金额。
让我们考虑餐厅人员在顾客的每张账单上加收 18% 的税。
用于计算税的逻辑是 -
value=(money + (money * 0.18));
这笔钱应该乘以18%并添加到钱中,然后餐厅人员可以从顾客那里收到含税的金额。
现场演示
#include<stdio.h> int main(){ float money,value; printf("enter the money with dollar symbol:"); scanf("%f",&money); value=(money + (money * 0.18)); printf("amount after adding tax= %f</p><p>",value); return 0; }
enter the money with dollar symbol:250$ amount after adding tax= 295.000000
让我们通过更改百分比来考虑相同的程序 -
现场演示
#include<stdio.h> int main(){ float money,value; printf("enter the money with dollar symbol:"); scanf("%f",&money); value=(money + (money * 0.20)); printf("amount after adding tax= %f</p><p>",value); return 0; }
enter the money with dollar symbol:250$ amount after adding tax= 300.000000
以上就是使用赋值运算符计算带税金额的C程序的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号