问题
填空题
以下程序运行后的输出结果是 【8】 。 #include <stdio.h> main() { int a=1,b=3,c=5; if (c=a+b) printf("yes\n"); else printf("no\n"); }
答案
参考答案:yes
解析: 程序if语句中是赋值表达式,而不是相等“==”运算。因为c=a+b中a+b的值为4,赋给c,c=4,表达式为真,输出yes。
以下程序运行后的输出结果是 【8】 。 #include <stdio.h> main() { int a=1,b=3,c=5; if (c=a+b) printf("yes\n"); else printf("no\n"); }
参考答案:yes
解析: 程序if语句中是赋值表达式,而不是相等“==”运算。因为c=a+b中a+b的值为4,赋给c,c=4,表达式为真,输出yes。