首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 #include main() { int y=1,x,a[]={2,4,6,8,10},*p; p=&a[1]; for( x=0; x<3; x++ ) y=y+*( p+x ); printf( "%d\n", y ); } 程序
有以下程序 #include main() { int y=1,x,a[]={2,4,6,8,10},*p; p=&a[1]; for( x=0; x<3; x++ ) y=y+*( p+x ); printf( "%d\n", y ); } 程序
admin
2019-07-14
16
问题
有以下程序
#include
main()
{ int y=1,x,a[]={2,4,6,8,10},*p;
p=&a[1];
for( x=0; x<3; x++ ) y=y+*( p+x );
printf( "%d\n", y );
}
程序运行后的输出结果是
选项
A、17
B、19
C、18
D、20
答案
B
解析
本题通过语句"p=&a[1]将指针变量p指向了存储单元a[1],即使得p[0]的值为4。然后通过3次for循环,x=0时,*(p+x)=*p=a[1]=4所以y=1+4=5;x=1时,*(p+x)=*(p+1)=a[2]=6,所以y=5+6=11;x=2时,*(p+x)=*(p+2)=a[3]=8,所以y=11+8=19。因此B选项正确。
转载请注明原文地址:https://kaotiyun.com/show/7ARp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下选项中,不能对主函数中变量i和j的值进行交换的程序是()。
有以下程序#includemain(){FILE*fp;inta[10]={1,2,3,0,0},i;fp=fopen("d2.dat","wb");fwrite(a,sizeof(int),5,fp);fwrite(a
有以下程序#includemain(){inta=1,b=2,c=3,x;x=(a^b)&c;printf("%d\n",x);}程序的运行结果是()。
设有定义:intx[2][3];则以下关于二维数组x的叙述错误的是()。
有三个关系R、S和T如下:则关系T是由关系R和S通过某种操作得到,该操作为( )。
有以下结构体说明、变量定义和赋值语句structSTD{charname[10];intage;charsex;}s[5],*ps;ps=&s[0];则以下scanf函数调用语句有错误的是
在数据库设计中,将E-R图转换成关系数据模型的过程属于
下面不属于软件设计阶段任务的是
层次型、网状型和关系型数据库划分原则是()。
下列对于软件测试的描述中正确的是
随机试题
国家公务员旷工直接违反了
缺铁性贫血对妊娠的影响哪项是错误的
使用强心苷类药物引起心脏中毒最早期的症状是
以轨束梁便桥增建小桥做法正确的有()。
下列防火门构造的基本要求中,正确的有()。
耀州窑代表着______艺术的最高成就。耀州窑遗址位于______市漆水河两岸,宋代有“十里窑场”之称。
下列哪几项属于性生活方面的教育内容?()
下列属于无效的行政行为的是()。
四年前,四川省某镇的1500余户农民向县丝绸公司交售了价值14万余元的蚕茧。但是,农民辛辛苦苦的劳动换来的不是现金,而是一张张白条。县人大代表得知此事后,提出了“要求县丝绸公司兑付农民白条”的议案。县人大常委会对这一涉及农户切身利益的议案高度重视,决定由县
索引是影响关系数据库性能的重要因素之一。下列关于索引的说法,错误的是
最新回复
(
0
)