首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序 #include <stdio.h> main() { int i, array[5] = {3, 5, 10, 4}; for (i=0; i<5; i++) printf("%d,", array[i] &
有如下程序 #include <stdio.h> main() { int i, array[5] = {3, 5, 10, 4}; for (i=0; i<5; i++) printf("%d,", array[i] &
admin
2020-06-16
25
问题
有如下程序
#include <stdio.h>
main()
{
int i, array[5] = {3, 5, 10, 4};
for (i=0; i<5; i++)
printf("%d,", array
& 3);
printf("\n");
}
程序运行后的输出结果是
选项
A、3,1,2,0,0,
B、3,5,10,4,0,
C、3,3,3,3,0,
D、3,2,2,2,0,
答案
A
解析
在对数组进行初始化时,如果在说明数组时给出了长度,但没有给所有的元素赋予初始值,而只依次给前面的几个数组元素赋予初值,那么C语言将自动对余下的元素赋初值0,则array={3,5,10,4,0}。按位与运算"&",当参加运算的两个二进制数的对应位都为1,则该位的结果为1,否则为0。将数组元素与3=11B按位与,即3&3=3,5&3=1,10&3=2,4&3=0,0&3=0。For循环输出与运算结果:3,1,2,0,0,A选项正确。
转载请注明原文地址:https://kaotiyun.com/show/MiCp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下列叙述中正确的是
以下选项中关于程序模块化的叙述错误的是
若变量已正确定义,则以下语句的输出结果是s=32;s^=32;printf("%d",s);
下列数据流图(DFD)构造规则中正确的是
以下选项中非法的字符常量是
设有课程关系模式:R(C#,Cn,T,TA)(其中,C≠≠为课程号,Cn为课程名,T为教师名,Ta为教师地址)并且假定不同课程号可以有相同的课程名,每个课程号下只有一位任课教师,但每位教师可以有多门课程。关系R中对主属性的传递依赖为
学生的记录由学号和成绩组成,N名学生的数据已放入主函数中的结构体数组S中。请编写函数fun,其功能是:把指定分数范围内的学生数据放在b所指的数组中,分数范围内的学生人数由函数值返回。例如,输入的分数是60、69,则应当把分数在60~69的学生数据输
如下所示的系统结构图的最大出扇数是()。
在关系数据库设计中,关系模式设计属于()。
结构化程序设计风格强调的是
随机试题
农业社会、工业社会及“过渡型”社会三种社会形态的差别主要体现在()
七情的致病特点有:()
诱发强心苷中毒的因素有
尤善治风湿痹证属下部寒湿者的药物是
硕士生毕业回家种地,父亲愤而服毒自杀,对此你怎么看?
土地整理是指通过采取各种措施,对田、水、路、林、村综合整治,提高耕地质量,增加有效耕地面积,改善农业生态条件和生态环境的行为。下列不属于土地整理的是()。
设z=e-x-f(x-2y),且当y=0时,z=x2,则=________。
Inthenextcenturywe’llbeabletoalterourDNAradically,encodingourvisionsandvanitieswhileconcoctingnewlife-forms.
Whetheryou’retheowneroftheDallasCowboysorcaptainoftheplaygrounddodgeballteam,thegoalinpickingplayersisthe
布达拉宫(PotalaPalace)是一座举世闻名的建筑群。它是世界上最高的古代宫殿,最高点达到3700米。布达拉宫占地总面积为36万平方米,主楼高117米,共13层。整座宫殿具有鲜明的藏式风格(Tibetanstyle)。布达拉宫堪称是一座各种艺术的
最新回复
(
0
)