问题 单项选择题

执行下列语句:
#include<iostream>
using namespace std;
int main()

int x=3;
if(x=5)
cout<<x++<<end1;
else
cout<<x<<end1;
return 0;

程序的输出是( )。

A.3

B.4

C.5

D.6

答案

参考答案:C

解析: if(条件)语句1 else语句2,语句的执行过程是:首先判断条件是否为真(不为0),为真则0执行语句1,否则执行语句2。题目中的条件是x=5,意思是把5赋予变量x,它将x置5且返回一个真值。

单项选择题
单项选择题