有以下程序: #include #define PT 4.5; #define s(x) PT *:x *x; main() {int a=1,b =2;printf("%4.1f\n",s(a+b));}

admin2016-12-25  7

问题 有以下程序:
    #include
    #define PT 4.5;
    #define s(x) PT *:x *x;
    main()
    {int a=1,b =2;printf("%4.1f\n",s(a+b));}
    输出结果为(    )

选项 A、8.5
B、40.5
C、程序有错
D、18

答案C

解析 宏定义不是C语句,末尾不需要分号,语句printf("%4.lf\n",s(a+b));展开后为printf("%4.lf\n",4.5;*a+b*a+b;);所以程序会出现错误。
转载请注明原文地址:https://kaotiyun.com/show/fVAx777K
0

最新回复(0)