下列程序的输出结果是 #include <iostream> using namespace std; int main () { char a [] = "Hello,World

admin2010-12-16  24

问题 下列程序的输出结果是       #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语句全部输出为大写字母。
转载请注明原文地址:https://kaotiyun.com/show/BOjp777K
0

最新回复(0)