有下列程序: #include<stdi0.h> voidmain( ) {inta=S,b=1,t; t=(a<<2)|b;printf("%d\n",t); } 程序运行后的输出结果是( )。A.21B.11C.6D.1

题目

有下列程序: #include<stdi0.h> voidmain( ) {inta=S,b=1,t; t=(a<<2)|b;printf("%d\n",t); } 程序运行后的输出结果是( )。

A.21

B.11

C.6

D.1


相似考题
参考答案和解析
正确答案:A
A。【解析】本题考查移位运算符在程序中对5逻辑左移2位,其值扩大4倍等于20,然后再进行按位运算,其值等于21。
更多“有下列程序: #include&lt;stdi0.h&gt; voidmain( ) {inta=S,b=1,t; t=(a&lt;&lt;2)|b;printf ”相关问题
  • 第1题:

    若下列程序执行后t的值为4,则执行时输入a,b的值范围是 #include ”stdio.h” main() { int a, b, s=1, t=1; scanf (”%d, %d”, &a, &b); if (a>0) s+=1; if (a>b) t+=s; else if(a==b) t=5; else t = 2*s; printf (”s=%d, t=%dn”, s,t); }


    0<a<b

  • 第2题:

    计算1!+2!+3!+4!+5!编程如下,程序中下划线处应填写__。 #include <stdio.h> void main() { int i; int t=__,s=__; for(i=1;i<6;i++) { t=t*i; s=s+t; } printf("1!+2!+3!+4!+5!=%dn",s); }


    A解析:Test类实现了Runnable接口。

  • 第3题:

    3、若下列程序执行后t的值为4,则执行时输入a,b的值范围是 #include ”stdio.h” main() { int a, b, s=1, t=1; scanf (”%d, %d”, &a, &b); if (a>0) s+=1; if (a>b) t+=s; else if(a==b) t=5; else t = 2*s; printf (”s=%d, t=%d\n”, s,t); }


    0<a<b

  • 第4题:

    【填空题】下列程序的输出结果是 。 #define SQR(t) t*t void main() {int a = 1, b=2, s; s = SQR(a * b); printf("%d", s); }


    12

  • 第5题:

    【填空题】下列程序的输出结果是 。 #define SQR(t) t*t void main() {int a = 1, b=2, s; s = SQR(a + b); printf("%d", s); }


    12