以下程序的输出结果是 ______。includevoid main(){ char s1[]=”Hello”,s2[]="World以下程序的输出结果是 ______。 #include<iostream.h> void main(){ char s1[]=”Hello”,s2[]="World"; char *p1,*p2; int i; p1=s1; p2=s2; for(i=0;i<5;i++) if(*(pl+i)==*(p2+i)) cout<<*(p1+i); }A.H1B.HoC.10D.

题目
以下程序的输出结果是 ______。includevoid main(){ char s1[]=”Hello”,s2[]="World

以下程序的输出结果是 ______。 #include<iostream.h> void main(){ char s1[]=”Hello”,s2[]="World"; char *p1,*p2; int i; p1=s1; p2=s2; for(i=0;i<5;i++) if(*(pl+i)==*(p2+i)) cout<<*(p1+i); }

A.H1

B.Ho

C.10

D.1


相似考题
更多“以下程序的输出结果是 ______。#include<iostream.h>void main(){ char s1[]=”Hello”,s2[]="World ”相关问题
  • 第1题:

    下列程序的输出结果为includevoid main( ){char * a[ ]={"hello","the","world"};c

    下列程序的输出结果为 #include<iostream.h> void main( ) { char * a[ ]={"hello","the","world"}; char * * pa=a; pa++; cout <<*pa<<end1; }

    A.hello

    B.the

    C.world

    D.hellotheworld


    正确答案:B
    解析:本题主要考查的是指针数组和指向指针的指针之间的关系,其中a是指针数组,pa是指向指针数组行的指针,所以pa自加1相当于指向下一行。

  • 第2题:

    下列程序的输出结果为includevoid main(){char*a[]={"hello","the","world"};char*

    下列程序的输出结果为 #include<iostream.h> void main() { char*a[]={"hello","the","world"}; char**pa=a; pa++; cout<<*pa<<end1; }

    A.hello

    B.the

    C.world

    D.hello the world


    正确答案:A
    解析:本题考查的是字符数组的初始化,选项B)中用3个元素初始化大小为2的数组,越界了;选项C)中应该是2行3列的数组,题中使用3行2列初始化;选项D)中数组合后应用方括号。

  • 第3题:

    以下程序的输出结果是( )。 include main() {char*s1,*s2,m; s1=s2=(char*)malloc(size

    以下程序的输出结果是( )。

    include<stdlib.h>

    main()

    {char*s1,*s2,m;

    s1=s2=(char*)malloc(sizeof(char));

    *s1=15;

    *s2=20;

    m=*s1+*s2:

    printf("%d\n",m);

    }


    正确答案:40
    40 解析:malloc()函数的作用是开辟一个长度为sizeof(char)的内存区,s1、s2为指向字符型数据的指针变量,执行“s1=s2=(char*)malloc(sizeof(chat));”语句后,s1、s2指向同一个存储空间,此时m=*s1+*s2=20+20=40。

  • 第4题:

    以下程序的输出结果是_______。includeincludefun(char*w,int n){char t,*s

    以下程序的输出结果是_______。 #include<stdio.h> #include<string.h> fun(char*w,int n) { char t,*s1,*s2; s1=w;s2=w+n-1; while(s1<s2) { t=*s1++: *sl=*s2-; *s2=t; } } main() { char*p; p="1234567"; fun(p,strlen(p)); puts(p); }

    A.1234567

    B.7654321

    C.1711717

    D.7177171


    正确答案:C
    解析:在于函数fun中,s1为字符串w的起始地址,s2为字符串的结束地址(字符'\0'除外),当执行循环结束循环,w="1711717"。

  • 第5题:

    下列程序的输出结果是 include usingnamespacestd; int main () {chara []="Hello,W

    下列程序的输出结果是 #include <iostream> using namespace std; int main () { char a [] = "Hello,World": char*ptr = a; while (*ptr) { if(*ptr>= 'a' &&*ptr <='z' cout<<char{*ptr+'A'-'a'); else cout<<*ptr; ptr++; } return 0; }

    A. HELLO. WORLD

    B. Hello, World

    C. hELLO, wORLD

    D. hello, world


    正确答案:A
    解析:本题考核while语句和if语句,while语句中if语句的作用是将小写字母变成大写字母输出、所以main函数的字符串通过while语句全部输出为大写字母。