首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是( )。 #include<stdio.h> main() { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+
下列程序的输出结果是( )。 #include<stdio.h> main() { int a=0,i; for(i=1;i<5;i++) { switch(i) { case 0: case 3:a+
admin
2010-09-05
77
问题
下列程序的输出结果是( )。
#include<stdio.h>
main()
{ int a=0,i;
for(i=1;i<5;i++)
{ switch(i)
{ case 0:
case 3:a+=1;
case 1:
case2:a+=2;
default:a+=3;
}
}
printf("%d",a);
}
选项
A、19
B、18
C、6
D、8
答案
A
解析
本题考查switch语句。当i=1时,执行 case 1,因为没有遇到break语句,所以依次往下运行, a=a+2=2,a=a+3=5 当i=2时,执行case2,因为没有遇到break语句,所以依次往下运行,a=a+2=7, a=a+3=10;当i=3时,执行case3,a=a+1=11,因为没有遇到break语句,所以依次往下运行,a=a+2=13, a=a+3=16;当i=4时,执行default,a=a+3=19,结束循环。
转载请注明原文地址:https://kaotiyun.com/show/0YWp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
假定有如下的程序段:DimintVarAsIntegerintvar=TruePrintintVar则输出结果是
编写如下程序:PrivateSubCommand1_Click()Dima(3,3)AsIntegerDimiAsInteger,jAsIntegerFori=1To3Forj=
下列程序的执行结果是()。PrivateSubForm_Activate()Dimscore(3)AsInteger,totalAsIntegerDimaa_scoreAsVariant
某人编写了如下程序,用来求10个整数(整数从键盘输入)中的最大值:PrivateSubCommand1_Click() Dima(10)AsInteger,maxAsInteger Fork=1To10 a(k)=In
在窗体上画一个名称为Command1的命令按钮,并编写如下程序:OptionBase1PrivateSubCommand1_Click() Dima(4,4) Fori=1To4 Forj=1To4
窗体上有一个名称为Command1的命令按钮,并有如下程序代码:PrivateSubCommand1_Click()Staticaa=1:b=2:c=3Callf(a,b,c)Print
某人编写了向随机文件中写一条记录的程序,代码如下:TypeRType NameAsString*10 TelAsString*20EndTypePrivateSubCommand1_Click() DimpA
编写如下程序:PrivateSubCommand1_Click() DimiAsInteger,jAsInteger n=InputBox("输入一个大于1的正整数") Fori=2Ton Forj=2To
随机试题
中国人民政治协商会议作为中国共产党领导的多党合作和政治协商的重要机构,其主要职能有()
Everyonehasgottwopersonalities—theonethatisshowntotheworldandtheotherthatissecretandreal.Youdon’tshowyour
Pickouttheappropriateexpressionsfromtheeightchoicesbelowandcompletethefollowingdialoguebyblackeningthecorrespo
A.期门B.石门C.天枢D.中脘E.中极胃经的募穴是
赵某因贪污罪被人民检察院提起公诉,在法庭审理,检察院要求传唤李某出庭作证。以下审判人员对李某的询问不符合刑事诉讼法规定的是:
有效组合与无差异曲线的切点所表示的组合,是投资者的最满意的有效组合。()
已知函数y(x)可微(x>0)且满足方程则y(x)=__________.
安全管理中涉及的安全机制有:身份验证、加密、密钥管理和______等。
ThegraphbelowshowsthequantitiesofgoodstransportedintheUKbetween1974and2002byfourdifferentmodesoftransport.
Earthquakescausevibrationstopass______aroundthegroundintheformofwaves.
最新回复
(
0
)