有以下程序 #define PT 3.5; #define S(x) PT*x*x ; main() { int a=1,b=2; print=f("%4.1 f\n",S(a+b));} 程序运行后的

admin2019-06-09  13

问题 有以下程序
    #define PT 3.5;
    #define S(x)  PT*x*x  ;
    main()  {
    int a=1,b=2;
    print=f("%4.1 f\n",S(a+b));}
    程序运行后的输出结果是

选项 A、31.5
B、7.5
C、程序有错无输出结果
D、14.0

答案C

解析 本题考查宏定义。预处理语句后面不能加分号,因此程序有错。如果没加分号的话S(a+b)=PT*a+b*a+b=3.5*1+2*1+2=7.5。
转载请注明原文地址:https://kaotiyun.com/show/cCRp777K
0

相关试题推荐
随机试题
最新回复(0)