全部题库 / C++ / 试题详情
单选题 C++
2013-08-06

下列程序的输出结果是(  )。
#included<iostream>
usingnamespacestd;
intmain()
{
chara[]="Hell0,Test";
char*p=a;
while(*p)
{
if(*p>='a'&&*p<='z')
cout<<char(*p+'A'-'a');
elsecout<<*P;
p++;
}
return0;
}

A.hello,test
B.Hello,Test
C.HELLO,TEST
D.hELLO,tEST

参考答案

C

答案解析

C。【解析】用一个指针变量p指向字符数组A,在while循环中,当不指向数组尾时,将小写字母转换为大写字母,然后将其输出。



你可能感兴趣的试题