niusouti.com

(25)有以下程序#include<stdio.h>void fun(char *s){while(*s){ if(*s%2==0) printf(“%c”,*s);s++;}}main(){ char a[]={“good”};fun(a);printf(“\n”);}注意:字母a的ASCII码值为97,程序运行后的输出结果是A)d B)go C)god D)good

题目

(25)有以下程序

#include<stdio.h>

void fun(char *s)

{while(*s)

{ if(*s%2==0) printf(“%c”,*s);

s++;

}

}

main()

{ char a[]={“good”};

fun(a);printf(“\n”);

}

注意:字母a的ASCII码值为97,程序运行后的输出结果是

A)d B)go C)god D)good


相似考题
参考答案和解析
正确答案:A
更多“(25)有以下程序 #include&lt;stdio.h&gt; void fun(char *s) {while(*s) { if(*s%2==0) prin ”相关问题
  • 第1题:

    有以下程序inc1udevoid fun(char*s){while(*s) {if(*s%2=0) printf("%c",*s); s++ }}m

    有以下程序 #inc1ude<stdio.h> void fun(char*s) { while(*s) { if(*s%2=0) printf("%c",*s); s++ } } main() { char a[]={"good"}; fun(A) ; prntf("n\"); } 注意:字母a的ASCII码值为97,程序运行后的输出结果是______。

    A.d

    B.go

    C.god

    D.good


    正确答案:A
    解析:本题主要考查函数的调用以及字符的ASCII码值,由while循环语句可知,如果字符的ASCII码值为偶数就输出该字符,否则不输出,因为s的ASSCII码值为103;o的码值为111,d的码值为100,所以程序输出结果是d,因此,选项A是正确的。

  • 第2题:

    有下列程序: include<stdi0.h>voidfun(char*s){while(*s){if(*s%2==(1)printf("%C&q

    有下列程序:

    #include<stdi0.h>

    voidfun(char*s)

    {while(*s)

    {if(*s%2==(1)printf("%C",*s);

    s+十:

    }

    }

    voidmain( )

    {chara[]={"good");

    fun(a);printf("n");

    }

    注意:字母a的ASCIl码值为97,程序运行后的输出结果是( )。

    A.d

    B.go

    C.god

    D.good


    正确答案:A
    A。【解析】在本题中,子函数fun(char*s)的功能是如果*s的ASCIl值是偶数,则输出*s,主函数中当实参的值为good时,9的ASCIl值是103,字母o的ASCIl值是111,字母d的ASCIl值是100,只有字母d的ASCIl值是偶数,所以输出字母d。

  • 第3题:

    (25)有以下程序(说明:字母A的ASCII码值是65)

    #include <stdio.h>

    void fun(char *s)

    { while(*s)

    { if(*s%2) printf("%c",*s);

    s++;

    }

    }

    main()

    { char a[]="BYTE";

    fun(a); printf("\n");

    }

    程序运行后的输出结果是

    A)BY

    B)BT

    C)YT

    D) YE


    正确答案:D

  • 第4题:

    以下程序的输出结果是()。includeint fun (char*s){char *p=s;while (*p!='\0,) p++

    以下程序的输出结果是( )。 #include<iostream.h> int fun (char*s) { char *p=s; while (*p!='\0,) p++: return (p-s): } void main() { cout<<fun (" ABCDEF ")<<endl: }

    A.3

    B.6

    C.8

    D.0


    正确答案:B

  • 第5题:

    有以下程序 include void fun(char *t,char *s) { while(*t!=0) t++; while((*t++=*s

    有以下程序

    #include <stdio.h>

    void fun(char *t,char *s)

    { while(*t!=0) t++;

    while((*t++=*s++)!=0);

    }

    main( )

    { char ss[10]="acc",aa[10]="bbxxyy";

    fun(ss,aa); printf("%s,%s\n",ss,aa);

    }

    程序的运行结果是

    A.accxyy,bbxxyy

    B.acc,bbxxyy

    C.accxxyy,bbxxyy

    D.accbbxxyy,bbxxyy


    正确答案:D
    解析:本题中fun函数实现了字符串函数strcat的功能,将字符串aa连接到字符串ss的末尾。调用fun函数时,形参t和s分别指向了字符串ss和aa,然后通过一个while循环使t指向字符串ss的结束符的位置,第二个while循环将字符串aa中的字符(包括结束符“\0”)逐个复制到字符串ss的末尾处。