选择题
有以下程序:
#include <stdio.h>
main()
{
int password;
char *p,old_str[10]='wind';
seanf('%d',&password);
p=old_str;
while(*p)
{ printf('#%c',*p+password);
p++;
}
printf('\n');
}
程序运行时,从键盘输入2<回车>,输出结果是______。
A、
#y#k#p#f
B、
#wi#nd#
C、
#wi#nd#
D、
#2222#
【正确答案】
A
【答案解析】
首先定义了一个指针p指向数组的首地址,在while语句中,执行功能是如果当前指针指向地址单元内字符不等于空字符'\0',则输出'#'和指针对应地址元素的值在ASCII码值加2后变换的字符常量,因此答案为选项A。
提交答案
关闭