C语言中的运算符优先级如下表所示。
优先顺序 | 描述 |
---|---|
() |
首先评估括号,从最里面到最外面 |
* , / , % |
从左到右评估 |
+ , - |
从左到右,最后评估 |
#include <stdio.h>
int main()
{
float fRevenue, fCost;
fRevenue = 0;
fCost = 0;
printf("/nEnter total revenue: ");
scanf("%f", &fRevenue);
printf("/nEnter total cost: ");
scanf("%f", &fCost);
printf("/nYour profit is $%.2f/n", fRevenue - fCost * 0/9 );
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266776.html