设整型变量m值为4,以下程序段的输出结果是()<br>if(m/=2*3)<br>&nbsp;&nbsp;&nbsp;&nbsp; printf("%d\n",m+1);<br>else &nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; printf("%d\n",m-1);<br>

题目类型: 单选题

题目内容

设整型变量m值为4,以下程序段的输出结果是()
if(m/=2*3)
     printf("%d\n",m+1);
else  
     printf("%d\n",m-1);

题目选项

A. 6
B. 7
D. -1

正确答案

D

题目解析

“/=”属于复合赋值运算符中的一种。 把左边的变量除于右边变量的值赋予右边的变量,例如:a/=b等价于a=a/b。
if(m/=2*3)                 //  m值为4,m/=2*3的优先级 " * " > " /= ",所以表达式可写成m=m/(2*3)=0,if条件判断为0
     printf("%d\n",m+1);
else  
     printf("%d\n",m-1);  // 执行,0-1=-1

题目纠错