执行下列程序的输出结果是()。  #include   #include    main( )  {   char a[

题目
填空题
执行下列程序的输出结果是()。  #include   #include    main( )  {   char a[80]=“AB”, b[80]= “LMNP”;       int i=0;      strcat(a,b);      while(a[i++]!=‘/0’)          b[i]=a[i];  puts(b); }
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

下列程序执行的输出结果是()。inClUdemain(){char a[2][4]; strcpy(a,"are");strcpy(a[

下列程序执行的输出结果是( )。 #inClUde<stdio.h> main() { char a[2][4]; strcpy(a,"are");strcpy(a[1],"you"); a[0][3]='&'; printf("%s\n",a); }

A.are&you

B.you

C.are

D.&


正确答案:A
解析: strcpy(a,"are")中数组名a代表数组首地址的地址常量,该操作把are复制到a中,a[0][3]='&',且strcpy(a[1],"you")把you复制到a[1]中,故输出a为“are&you”。

第2题:

以下程序运行后的输出结果是【】include main ( ) {char a[] ="123456789", *p;int i =0;

以下程序运行后的输出结果是【 】

include <stdio.h>

main ( )

{ char a[] ="123456789", *p;

int i =0;

p=a;

while( * p)

{ if(i%2 ==0) *p='*';

p++;i++;

}

puts(a);

}


正确答案:*2*4*6*8*
*2*4*6*8* 解析:程序中指针p指向数组a,while(*P)语句的循环条件是* p!='\0',在循环体中,当 i=0,2,4,6,8时,i%2=0,执行*p='*',即a[i]='*',继续执行p++;i++;使i为奇数;当i=1, 3,5,7时,i%2=1,继续执行p++;i++;使i为偶数。可见,程序在字符串"123456789",的下标为偶数的位置上赋值'*',代替原字符串中的1,3,5,7,9。所以,程序输出结果为*2*4*6*8*。

第3题:

以下程序的输出结果是【】。 include using namespace std; int main() {char S[]="abcde

以下程序的输出结果是【 】。

include <iostream>

using namespace std;

int main()

{

char S[ ]="abcdef";

s[3]='\0';

cout<<s<<end1;

return 0;

}


正确答案:abc
abc 解析:字符串的结束标记是'\0',当输出一个存放在字符数组中的字符串时,只需输出到'\0'为止,而不管其后还有什么数据。本题给字符数组s的元素s[3]赋值'\0',故只能输出3个字符“abc”。

第4题:

以下程序的输出结果是【】。 include include void main 0 { char s[50]; st

以下程序的输出结果是【 】。

include<iostream.h>

include <string.h>

void main 0 {

char s[50];

strcpy(&s[O], "No" );

strcpy(&s[1], "123" );

strcpy (&s[2], "23456" );

cout<<s;

}


正确答案:N123456
N123456

第5题:

下面程序的输出结果是( )。 include main() {static char a[]="china"; char*ptr=a; whi

下面程序的输出结果是( )。 include<stdio.h> main() {static char a[]="china"; char*ptr=a; while(*ptr) {printf("%c",*ptr-32); ptr++; } }


正确答案:CHINA
CHINA

第6题:

执行如下程序后的输出结果是【】。include include using namespace std;int ma

执行如下程序后的输出结果是【 】。

include <iostream>

include <fstream>

using namespace std;

int main ( )

{

char s[25];

ofstream fl("data.txt");

f1<<"C++ Programming";

f1.close ();

ifstream f2 ("data.txt");


正确答案:C++
C++ 解析:程序先在当前目录下建立一个data文本文件,并写入“C++ Programming”。然后打开该文件,将其中的数据输入到变量s中,由于采用提取符“>>”读时遇到空格终止,所以最后字符数组s中存放的是“C++”。

第7题:

执行下列程序的结果是( )。 include void main() { char *str; str

执行下列程序的结果是( )。 #include<iostream.h> void main() { char *str; str="test!"; cout<<str[5]; }

A.test!

B.test

C.空字符

D.异常


正确答案:C
解析:字符指针str值为“test!”,它们的下标由0开始,并且具有一个尾符,输出str[5]的位置为尾符标识,指针字符指向的尾符为空。所以答案为空字符。

第8题:

下列程序的输出结果是______。 include include using namespace std; voi

下列程序的输出结果是______。

include<iostream.h>

include<string.h>

using namespace std;

void fun(const char*s,char &C) {c=s[strlen(s)/2];}

int main()

{

char str[]="ABCDE";

char ch=str[1];

fun(str,ch);

cout<<ch;

return 0;

}


正确答案:C
C

第9题:

下面程序运行输出的结果是【】。 include using namespace std; int main(){char a[]="C

下面程序运行输出的结果是【 】。

include <iostream>

using namespace std;

int main(){

char a[]="Chinese";

a[3]='\0';

cout<<a<<endl;

return 0;

}


正确答案:Chi
Chi 解析:字符串的结束标识是'\0',输出字符串时,到第一个'\0'输出结束,而不管其后是否还有数据,因此本题输出为字符中的前3个字符。

第10题:

下列程序的输出结果是【】。 include include void main(){ char b[30]; str

下列程序的输出结果是【 】。

include<iostream.h>

include<string.h>

void main(){

char b[30];

strcpy(&b[0],"XY");

strcpy(&b[1],"YZW");

strcpy(&b[2],"ZXY");

cout<<b<<end1;

}


正确答案:XYZXY
XYZXY

更多相关问题