A-A+

下列程序的输出结果是 #inClUde<iostream> using namespace

2022-08-06 04:13:02 问答库 阅读 175 次

问题详情

下列程序的输出结果是
#inClUde<iostream>
using namespace std;
intmain()
{
Char a[]="HellO,World";
Char*ptr=a;
while(*ptr)
{
if(*ptr>="a"&& *ptr <="Z")
cout<<char(*ptr+"A" -"a");
else cout<<*ptr;
ptr++;
}
retur0;
}
A.HELLO,WORLD
B.Hello,world
C.hELLO,wORLD
D.hellO,world

参考答案

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

考点:程序