#define in C:发生了什么 [英] #define in C: what is happening
本文介绍了#define in C:发生了什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以解释每一步发生了什么吗?我知道最终输出是 140.5,但我不确定为什么会这样.导致 140.5 的每一行发生了什么?
Can someone explain what is happening at every step? I know the final output is 140.5, but I am unsure why that is. What is happening at each line that is resulting in 140.5?
#define PI 3.1
#define calcCircleArea(r) (PI * (r) * (r))
#define calcCylinderArea(r,h) (calcCircleArea(r) * h)
int main() {
double i = calcCylinderArea(3.0,5.0 + 1); printf("%g", i);
}
推荐答案
Step 0
calcCylinderArea(3.0,5.0+1)
步骤 1
(calcCircleArea(3.0)*5.0+1)
注意不是(5.0+1)
.
问题从这里开始.
notice that it is not (5.0+1)
.
Problem begins here.
((PI*(3.0)*(3.0))*5.0+1)
步骤 3
((3.1*(3.0)*(3.0))*5.0+1)
这篇关于#define in C:发生了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文