首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
若有以下程序 #include main() {chara[20],b[]="Theskyisblue.";inti; for(i=0;i<7;i++)scanf("%c",&b[i]); gets(a);printf("%s%s\n",a,b); } 执
若有以下程序 #include main() {chara[20],b[]="Theskyisblue.";inti; for(i=0;i<7;i++)scanf("%c",&b[i]); gets(a);printf("%s%s\n",a,b); } 执
admin
2015-07-31
17
问题
若有以下程序
#include
main()
{chara[20],b[]="Theskyisblue.";inti;
for(i=0;i<7;i++)scanf("%c",&b
);
gets(a);printf("%s%s\n",a,b);
}
执行时若输入:(其中
表示回车符)
Figflowerisred.
则输出结果是
选项
A、wer is red.Fig flo is blue.
B、wer is red.Fig flo
C、wer is red.The sky is blue.
D、Fig flower is red.The sky is blue.
答案
A
解析
程序首先初始化字符数组b[],执行for循环语句,循环变量i的取值范围从0到6。在for循环语句中通过scanf函数将从键盘上输入的数据输入到b[ ]中,即b的值为Fig flo is blue.。退出for循环语句,执行语句gets(a); ,gets()函数的调用形式为:gets(str_adr),其中str_adr是存放输入字符串的起始地址,可以是字符数组名、字符数组元素的地址或字符指针变量。gets函数用来从终端键盘读入字符串(包括空格符),直到读入一个换行符为止,即a的值为wer is red.。因此A选项正确。
转载请注明原文地址:https://kaotiyun.com/show/ABDp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下程序段给数组所有的元素输入数据,请选择正确答案填入。#include<stdio.h>main(){inta[10],i=0;while(i<10)scanf("%d",______);
下面程序main(){intx=32;printf("%d\n",x=x<<1);}的输出是______。
设有定义:intn1=0,n2,*p=&n2,*q=&nl;,下列赋值语句中与n2=n1;语句等价的是()。
若w、x、y、z、m均为int型变量,则执行下列的语句后m的值是()。w=2,x=3,y=4,z=5;m=(w<x)?w:x;m=(m<z)?m:z;m=(m<y)?m:y;
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下列图符名标识的图符不属于数据流图合法图符的是()。
若x为int类型,请写出与!x等价的C语言表达式______。
利用fseek函数可实现的操作是()。
下列叙述中,错误的是()。
随机试题
根据供求关系,某种商品的最低价格通常是由其________的多少来决定的。
2018年11月5日,首届中国国际进口博览会开幕。国家主席习近平出席开幕式并发表主旨演讲,宣布中国扩大开放新举措。此次博览会的举办城市是()
诊断青少年牙周炎时,可查出主要致病菌是()
病毒性肝炎的临床类型不包括
[2014年,第110题]某项目第一年年初投资5000万元,此后在第一年年末开始每年年末有相同的净收益,收益期为10年,寿命期结束时的净残值为100万元,若基准收益率为12%,则要使该投资方案的净现值为零,其年净收益应为()[已知(P/A,12%,
允许税前扣除的业务招待费为()。允许税前扣除的公益救济性捐赠额为()。
甲公司为连环漫画的创作者,2×17年1月1日,向客户授予的许可证使客户可在4年内使用其3份连环漫画中的角色和名称。每份连环漫画都有主角。但是会定期出现新创造的角色,且角色的形象在随时演变。该客户是大型游轮的运营商,其能够依据合理的方法以不同形式(例如节目或
网络规划中最主要的成本是()。
简述激发与维持内在学习动机的措施。
下列叙述中,正确的是
最新回复
(
0
)