以下程序运行后的输出结果是【 】。 main() {char c; int n=100; float f=10; double x; x=f*=n/=(c=50); printf("%d %f\n",

admin2013-02-23  31

问题 以下程序运行后的输出结果是【 】。
main()
   {char  c;  int  n=100;
      float  f=10;  double  x;
      x=f*=n/=(c=50);
      printf("%d  %f\n",n,x);
   }

选项

答案2  20.000000

解析 由于赋值运算符按照“自右而左”的结合顺序,题中赋值表达式“x=f*=n/=(c=50)”的求解步骤如下:首先,进行“n/=(c=50)”的运算,相当于n=n/c=100/50=2;其次,进行“f*=n”的运算,相当于“f=f*n”,故f=20.000000;最后,得出x的值为20.000000。
转载请注明原文地址:https://kaotiyun.com/show/lpPp777K
0

最新回复(0)