有以下程序:
#include<strintg.h>
main
{ char p[20]={'a','b','c','d'),q[]="abc",r[]="
abcde";
strcpy(p+strlen(q),r);strcat(p,q);
printf("%d%d\n",sizeof(p),strlen(p));
}
程序运行后的输出结果是( )。
A.20 9
B.9 9
C.20 11
D.11 11
第1题:
有以下程序 #include<string.h> main() { char p[20]={'a','b','c','d'},q[]="abc",r[]="abcde"; strcpy(p+strlen(q),r);strcat(p,q); printf("%d%d\n",sizeof(p),strlen(p)); } 程序运行后的输出结果是
A.20 9
B.9 9
C.20 11
D.11 11
第2题:
有以下程序: #include <stdlib.h> main() { char *p,*q; p=(char*)malloc(sizeof(char)*20); q=p; scanf("%s%s",p,q); ptintf("%s%s\n",p,q); } 若从键盘输入abc def<回车>,则输出的结果是( )。
A.def def
B.abc def
C.abc d
D.d d
第3题:
有以下程序
#include <stdio.h>
void fun(char **p)
{ ++p; printf("%s\n",*p);}
main()
{ char *a[]={"Morning","Afternoon","Evening","Night"};
fun(a);
}
程序的运行结果是
A ) Afternoon
B ) fternoon
C ) Morning
D ) orning
第4题:
有以下程序: # include<string.h> main() { char str[][20]={"Hello","Beijing"},*p=str; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是 ______。
A.0
B.5
C.7
D.20
第5题:
有以下程序: #include<string.h> main() {char p[20]={'a','b','c','d'),q[]="abc",r[]="abcde" strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",sizeof(p)); } 程序运行后的输出结果是( )。
A.9
B.6
C.11
D.7
第6题:
有以下程序 #include<string.h> main() { char p[20]={'a','b','c','d'},q[]="abc",r[]="abcde"; strcat(p,r);strcpy(p+strlen(q),q); printf("%d\n",strlen(p)); } 程序运行后的输出结果是
A.9
B.6
C.11
D.7
第7题:
有以下程序: #include<stdio.h> void fun(char**p) { ++P;printf("%s\n",*p);} main() char*a[]={"Morning","Afternoon","Evening","Night"}; fun(A); } 程序的运行结果是( )。
A.Afternoon
B.fternoon
C.Morning
D.oring
第8题:
有以下程序
main()
{ char *p[]={"3697","2584"};
int i,j; long num=0;
for(i=0;i<2;i++)
{j=0;
while(p[i][j]!='\0')
{ if((p[i][j]-'0') % 2)num=10*num+p[i][j]-'0';
j+=2;
}
}
printf(" % d\n",num);
}
程序执行后的输出结果是
A)35
B)37
C)39
D)3975
(42)C) 解析 : while(p[i][j]!='\0') 表示 p[i][j] 不等于 '\0' 时 , 继续执行 while 中的语句。 if 语句表示(p[i][j]-'\0') 除 2 的余数不为 0 时 , 执行后面的语句。最后执行的结果是 39 。
第9题:
有以下程序: # include<stdio.h> main() { char*p,*q; p=(char *)malloc(sizeof(char)* 20);q=p; scanf("%s %s",p,q);printf("%s %s\n",p,q); } 若从键盘输入;abc def<回车>,则输出结果是 ______。
A.def def
B.abc def
C.abe d
D.d d
第10题:
有以下程序:
void funl(char*p)
{ char*q;
q=P;
while(*q!='\O')
{(*q)++;q++;}
}
main
{ char a[]={"Program"),*P;
p=&a[3];funl(p);
printf("%s\n",a);
}
程序执行后的输出结果是( )。
A.Prohsbn
B.Prphsbn
C.Progsbn
D.Program