niusouti.com

下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。includeunion pw{int下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。#include<stdio.h>union pw{ int i;char ch[2];}a;main (){ a.ch[0]=13;a.ch[1]=0; printf("%d\n",a.i);}A.13B.14C.208D.209

题目
下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。includeunion pw{int

下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。#include<stdio.h>union pw{ int i;char ch[2];}a;main (){ a.ch[0]=13;a.ch[1]=0; printf("%d\n",a.i);}

A.13

B.14

C.208

D.209


相似考题
更多“下列程序(注意:ch[0]在低字节,ch[1]在高字节)的输出结果是______。#include<stdio.h>union pw{int ”相关问题
  • 第1题:

    下列程序运行时,若输入labcedf2df<回车>输出结果为【】。 include main(){char a=0,ch; wh

    下列程序运行时,若输入labcedf2df<回车>输出结果为【 】。

    include<stdio.h>

    main()

    { char a=0,ch;

    while((ch==getchar())!='\n')

    { if(a%2!=0&&(ch>='a'&&ch<='z')) ch=ch'a'+'A';

    a++;prtchar(ch);

    }

    printf("\n");

    }


    正确答案:1AbCeDf2dF
    1AbCeDf2dF 解析:本题的执行过程是先从键盘上获得—个字符,判断是不是换行符,如果不是则继续执行循环体,再判断字符变量 a是否是偶数以及是否是小写字母,如果a不是偶数且输入的字符为小写字母,则将其转换成大写字母,接着执行a++;语句,变量a自增1,输出字符,因此本题的输出结果为1AbCeDF2dF(a相当于用来记录当前的顺序,即是第偶数个字符还是第奇数个字符)。
    字符位数:0 123456789
    输入字符:1 abcedf2df
    输出字符:1 AbCeDf2dF

  • 第2题:

    下面程序的输出结果是______。includemain(){char ch[7]={"12ab56"}; int i,s=0; for(i

    下面程序的输出结果是______。 #include<stdio.h> main() { char ch[7]={"12ab56"}; int i,s=0; for(i=0;ch[i]>='0'&&ch[i]<='9';i+=2) s=10*s+ch[i]-'0'; printf("%d\n",s); }

    A.1

    B.1256

    C.12ab56

    D.1 2 5 6


    正确答案:A
    解析:for语句中的条件表达式决定了循环体只执行一次。因此s=0*10+1,于是输出结果为1。

  • 第3题:

    19、下面程序执行后的输出结果是()。 #include <stdio.h> int main() { union { char ch[2]; short d; } s; s.d=0x4321; printf("%x,%x",s.ch[0],s.ch[1]); return 0; }

    A.21,43

    B.43,21

    C.43,00

    D.21,00


    A

  • 第4题:

    有以下程序:include main(){union{charch[2];int d;} s;s.d=0x4321;printf("%x,%x\n",

    有以下程序: #include <stdio.h> main() { union { charch[2]; int d; } s; s.d=0x4321; printf("%x,%x\n",s.ch[0],s.ch[1]); } 在16位编译系统上,程序执行后的输出结果是( )。

    A.21,43

    B.43,21

    C.43,00

    D.21,00


    正确答案:A
    解析:int型变量和字符数组ch共用两个字节的存储单元,通常ch[0]位于低字节,ch[1]位于高字节,所以s.ch[0]=21,s.c[1]=43。

  • 第5题:

    有以下程序:includeunion pw{int i; char ch[2]; } a;main(){a.ch[0]=13; a.ch[1]=0;

    有以下程序: #include <stdio.h> union pw { int i; char ch[2]; } a; main() { a.ch[0]=13; a.ch[1]=0; printf("%d\n",a.i); } 程序的输出结果是(注意:ch[0]在低字节,ch[1]在高字节)( )。

    A.13

    B.14

    C.208

    D.209


    正确答案:A
    解析:根据共用体的定义可知:共用体a的成员i和成员ch[2]共用同一段内存空间,所以,当程序给a.ch[0]和a.ch[1]赋值后,实际上,共用体成员i的值就确定为13了,所以打印输出的结果应当为13。