chapter26e.docx

上传人:b****8 文档编号:9807402 上传时间:2023-02-06 格式:DOCX 页数:14 大小:16.43KB
下载 相关 举报
chapter26e.docx_第1页
第1页 / 共14页
chapter26e.docx_第2页
第2页 / 共14页
chapter26e.docx_第3页
第3页 / 共14页
chapter26e.docx_第4页
第4页 / 共14页
chapter26e.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

chapter26e.docx

《chapter26e.docx》由会员分享,可在线阅读,更多相关《chapter26e.docx(14页珍藏版)》请在冰豆网上搜索。

chapter26e.docx

chapter26e

TRUE/FALSE

1.Inthefollowingcodefragment,xhasthevalueof3.

intx=3;

ANSWER:

TRUE

2.Thebodyofado-whileloopalwaysexecutesatleastonce.

ANSWER:

TRUE

3.Thebodyofawhileloopmayneverexecute.

ANSWER:

TRUE

4.Theoppositeof(x>3&&x<10)is(x<3&&x>10)

ANSWER:

FALSE

5.Theinteger0isconsideredtrue.

ANSWER:

FALSE

6.Loopsareusedwhenweneedourprogramtomakeachoicebetweentwoormorethings.

ANSWER:

FALSE

7.Itislegaltodeclaremorethanonevariableinasinglestatement.

ANSWER:

TRUE

8.Variablenamesmaybeginwithanumber.

ANSWER:

FALSE

9.Theoppositeoflessthanisgreaterthan

ANSWER:

FALSE

10.Everylineinaprogramshouldhaveacomment.

ANSWER:

FALSE

ShortAnswer

1.<

ANSWER:

insertion

2.Thebracesforaloopdefinethe____________oftheloop.

ANSWER:

body

3.Aloopthatalwaysexecutestheloopbodyatleastonceisknownasa_____________loop.

ANSWER:

do-while

4.intmyValue;iscalleda_______________________.

ANSWER:

variabledeclaration

5.Whatistheoppositeof(x<20&&x>12)?

_______________________

ANSWER:

(x>=20||x<=12)

6.Whatisthecorrectconditionalstatementtodetermineifxisbetween19and99?

__________________

ANSWER:

(x>19&&x<99)

7.Eachtimealoopbodyexecutesisknownasan_______________________.

ANSWER:

iteration

8.if-elsestatementsthatareinsideotherif-elsestatementsaresaidtobe_______________.

ANSWER:

nested

9.>>isknownasthe____________operator.

ANSWER:

extraction

10.Is<

____________

ANSWER:

output

11.Thestreamthatisusedforinputfromthekeyboardiscalled___________.

ANSWER:

cin

12.Thestreamthatisusedforoutputtothescreeniscalled___________.

ANSWER:

cout

13.Writetheloopconditiontocontinueawhileloopaslongasxisnegative.____________________

ANSWER:

while(x<0)

14.Whenmustweusebracestodefinethebodyofacontitionalexpression?

______________

ANSWER:

Whentherearemultiplestatementsinthebody.

15.Inacompoundlogicaland(&&)expression,theevaluationoftheexpressionstopsonceoneofthetermsoftheexpressionisfalse.Thisisknownas______________evaluation.

ANSWER:

short-circuitevaluation

MultipleChoice

1.Whichofthefollowingisavalididentifier?

a.3com

b.three_com

c.3_com

d.3-com

e.dollar$

ANSWER:

C(shouldbeB)

2.Whichofthefollowingisnotavalididentifer?

a.return

b.myInt

c.myInteger

d.total3

ANSWER:

A

3.Whatisthevalueofxafterthefollowingstatements?

intx,y,z;

y=10;

z=3;

x=y*z+3;

a.Garbage

b.60

c.30

d.33

ANSWER:

D

4.Whatisthevalueofxafterthefollowingstatements?

intx;

x=0;

x=x+30;

a.0

b.30

c.33

d.garbage

ANSWER:

B

5.Whatisthevalueofxafterthefollowingstatements?

intx;

x=x+30;

a.0

b.30

c.33

d.garbage

ANSWER:

D

6.Whatistheoutputofthefollowingcode?

floatvalue;

value=33.5;

cout<

a.33.5

b.33

c.value

d.garbage

ANSWER:

A

7.Whatistheoutputofthefollowingcode?

floatvalue;

value=33.5;

cout<<"value"<

a.33.5

b.33

c.value

d.garbage

ANSWER:

C

8.Whatistheoutputofthefollowingcode?

cout<<"Thisisa\\"<

a.Thisisa

b.Thisisa\

c.nothing,itisasyntaxerror

d.Thisisa\endl

ANSWER:

B

9.WhichofthefollowinglinescorrectlyreadsavaluefromthekeyboardandstoresitinthevariablenamedmyFloat?

a.cin>>myFloat;

b.cin<

c.cin>>"myFloat";

d.cin>>myFloat>>endl;

ANSWER:

A

10.Anotherwaytowritethevalue3452211903is

a.3.452211903e09

b.3.452211903e-09

c.3.452211903x09

d.3452211903e09

ANSWER:

A

11.WhichofthefollowingstatementsisNOTlegal?

a.charch='b';

b.charch='0';

c.charch=65;

d.charch="cc";

ANSWER:

D

12.Whatisthevalueofxafterthefollowingstatements?

floatx;

x=15/4;

a.3.75

b.4.0

c.3.0

d.60

ANSWER:

C

13.Whatisthevalueofxafterthefollowingstatements?

intx;

x=15/4;

a.15

b.3

c.4

d.3.75

ANSWER:

B

14.Whatisthevalueofxafterthefollowingstatements?

intx;

x=15%4;

a.15

b.4

c.3

d.3.75

ANSWER:

C

15.Whatisthevalueofxafterthefollowingstatement?

floatx;

x=3.0/4.0+3+2/5

a.5.75

b.5.75

c.1.75

d.3.75

ANSWER:

D

16.Whatisthevalueofxafterthefollowingstatement?

floatx;

x=3.0/4.0+(3+2)/5

a.5.75

b.5.75

c.1.75

d.3.75

ANSWER:

C

17.Whatisthevalueofxafterthefollowingstatements?

doublex;

x=0;

x+=3.0*4.0;

x-=2.0;

a.22.0

b.12.0

c.10.0

d.14.0

ANSWER:

C

18.Giventhefollowingcodefragmentandtheinputvalueof4.0,whatoutputisgenerated?

floattax;

floattotal;

cout<<"enterthecostoftheitem\n";

cin>>total;

if(total>=3.0)

{

tax=0.10;

cout<

}

else

{

cout<

}

a.3

b.3.3

c.4.0

d.4.4

ANSWER:

D

19.Giventhefollowingcodefragmentandtheinputvalueof2.0,whatoutputisgenerated?

floattax;

floattotal;

cout<<"enterthecostoftheitem\n";

cin>>total;

if(total>=3.0)

{

tax=0.10;

cout<

}

else

{

cout<

}

a.2.2

b.2.0

c.3.1

d.4.4

ANSWER:

B

20.Ifxhasthevalueof3,yhasthevalueof-2,andwis10,isthefollowingconditiontrueorfalse?

if(x<2&&w

a.true

b.false

ANSWER:

B

21.Whatisthecorrectwaytowritetheconditiony

a.(y

b.((y

c.((y>x)||(y

d.((y

ANSWER:

D

22.Giventhefollowingcodefragment,andaninputvalueof3,whatistheoutputthatisgenerated?

intx;

cout<<"Enteravalue\n";

cin>>x;

if(x=0)

{

cout<<"xiszero\n";

}

else

{

cout<<"xisnotzero\n";

}

a.xiszero

b.xisnotzero

c.unabletodetermine

d.xis3

ANSWER:

A(noteitisanassignment!

23.Giventhefollowingcodefragment,andaninputvalueof5,whatistheoutput?

intx;

if(x<3)

{

cout<<"small\n";

}

else

{

if(x<4)

{

cout<<"medium\n";

}

else

{

if(x<6)

{

cout<<"large\n";

}

else

{

cout<<"giant\n";

}

}

}

a.small

b.medium

c.large

d.giant

ANSWER:

C

24.Giventhefollowingcodefragment,whatistheoutput?

intx=5;

if(x>5)

cout<<"xisbiggerthan5.";

cout<<"Thatisall.";

cout<<"Goodbye\n";

a.xisbiggerthan5.Thatisall

b.xisbiggerthan5

c.Thatisall.Goodbye

d.Goodbye

ANSWER:

C

25.Executingoneormorestatementsoneormoretimesisknownas:

a.selection

b.iteration

c.sequence

d.algorithm

ANSWER:

B

26.Giventhefollowingcodefragment,whatisthefinalvalueofy?

intx,y;

x=-1;

y=0;

while(x<=3)

{

y+=2;

x+=1;

}

a.2

b.10

c.6

d.8

ANSWER:

B

27.Giventhefollowingcodefragment,whatisthefinalvalueofy?

intx,y;

x=-1;

y=0;

while(x<3)

{

y+=2;

x+=1;

}

a.2

b.10

c.6

d.8

ANSWER:

D

28.Whatistheoutputofthefollowingcodefragment?

intx=0;

while(x<5)

cout<

x++;

cout<

a.0

b.5

c.4

d.unabletodetermine

ANSWER:

D(infiniteloop)

29.Whatisthefinalvalueofxafterthefollowingfragmentofcodeexecutes?

intx=0;

do

{

x++;

}while(x>0);

a.8

b.9

c.10

d.11

e.infiniteloop.

ANSWER:

E

30.Giventhefollowingcodefragment,whichofthefollowingexpressionsisalwaystrue?

intx;

cin>>x;

a.if(x<3)

b.if(x==1)

c.if((x/3)>1)

d.if(x=1)

ANSWER:

D

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1