C++面向?qū)ο蟪绦蛟O(shè)計(jì)考試題庫_第1頁
C++面向?qū)ο蟪绦蛟O(shè)計(jì)考試題庫_第2頁
C++面向?qū)ο蟪绦蛟O(shè)計(jì)考試題庫_第3頁
C++面向?qū)ο蟪绦蛟O(shè)計(jì)考試題庫_第4頁
C++面向?qū)ο蟪绦蛟O(shè)計(jì)考試題庫_第5頁
已閱讀5頁,還剩144頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

SHORTANSWER

1.Asetofinstructionsthatthecomputerwillfollowiscalleda.

Answer:program

2.Thecollectionofprogramsusedbythecomputerisknownas.

Answer:software

3.Computersthatareinterconnectedareknownasa.

Answer:network

4.Adigitthatcanholdazerooraoneisknownasa.

Answer:bit

5.Listatleasttwoinputdevices.

Answer:keyboard,mouse,networkcard,file

6.Listatleasttwooutputdevices.

Answer:screen,printer,file,networkcard

7.Avariablethatcanholdawholenumberiscalleda(n).

Answer:integer

8.WhatpunctuationsignifiestheendofaC++statement?

Answer:Asemicolon.

9.Amistakeinacomputerprogramiscalleda.

Answer:bug

10.AistheprogramthattranslatesaprogramwritteninC++intomachine

language.

Answer:compiler

11.Errorsinaprogramcanbeclassifiedintothreetypes,listthem

Answer:Syntax,logic,run-time

12.WhatdoesthefollowingstatementinC++printtothescreen?

cout?“HellostudentsXn”;

Answer:Hellostudents.

13.Amistakethatisadirectviolationofthesyntaxruleswillgenerateacompiler.

Answer:error

14.Ifyourprogramcompilesandnins,butgivesanincorrectoutput,thisisknownasa

error.

Answer:logic

15.Thepartofthecomputerthatcontrolsandexecutesprogramsiscalledthe.

Answer:CPU

MULTIPLECHOICE

1.WhowastheprogrammerforCharlesBabbage'sanalyticalengine?

a.GraceHopper

b.AdaLovelace

c.LordBryan

d.WalterSavilch

Answer:B

2.Analgorithmis

a.Theinputsandoutputsofaprogram

b.Thepartofthecomputerthatdoestheprocessing

c.Afinitesetofstepstosolveaproblem

d.AcompletecomputerprogramAnswer:C

3.Amemoryaddressis

a.Whereavariableisstored

b.Wherethecomputerislocated

c.Astepintheprogram.

d.WheretheCPUisstored.Answer:A

4.Acomputerthatisnormallyusedbyonlyonepersonatatimeiscalleda

a.Server

b.Mainframe

c.PersonalComputer

d.NetworkAnswer:C

5.Thephysicalmachinesthatmakeupacomputeriscalledthe

a.Software

b.Network

c.Devices

d.CPU

e.HardwareAnswer:E

6.Whichofthefollowingisnotaphaseoftheprogram-designprocess?

a.Problem-solving

b.Implementation

c.MarketingthefinalprogramAnswer:C

7.WhichofthefollowingisnotpartoftheSoftwareLifeCycle?

a.Analysis

b.Design

c.DataEntry

d.Implementation

e.TestingAnswer:C

8.FromwhichlanguagedidC++directlyevolve?

a.A

b.Ada

c.C

d.C+

e.C-Answer:C

9.Whatdoesthefollowinglineofcodedisplaytothescreen?

cout?”Thisisthecomputer\nprogrammingbook\n,\

a.Thisisthecomputemprogrammingbook

b.Thisisthecomputer

c.Nothing

d.ThisisthecomputerprogrammingbookAnswer:D

2

10.C++statementsendwitha

a.Period

b.Comma

c.Semicolon

d.NothingAnswer:C

11.Whichofthefollowingisnotanexampleofaprogrambug?

a.Run-timeerror

b.Operatorerror

c.Syntaxerror

d.LogicerrorAnswer:B

12.Whatdoesthefollowingcodeprinttothescreen?

cout?”hello”;

a.Hello

b.hello

c.HELLO

d.NothingAnswer:B

13.Thesetofinstructionsthatacomputerwillfollowisknownas:

a.Hardware

b.Algorithm

c.Program

d.CPUAnswer:C

14.TheanagramCPUstandsfor

a.ComputerProgrammingUnit

b.CentralProcessingUnit

c.CentralProgramUser

d.ComputerPaperUserAnswer:B

15.Theoutputofthecompileriscalled

a.Theprogram

b.Sourcecode

c.Linkedcode

d.ObjectcodeAnswer:D

16.ThetermOSstandsfor

a.OperatingSystem

b.OscillatingSystem

c.OperationsServices

d.NothingAnswer:A

17.Whodesignedthefirstprogrammablecomputer?

a.IBM

b.Microsoft

c.Intel

d.Babbage

e.DellAnswer:D

3

18.Afinitesequenceofpreciseinstructionsthatleadstoaproblemsolutionis

a.Aprogram

b.TheCPU

c.AListofInputsandOutputs

d.AnAlgorithmAnswer:D

19.WhodevelopedC++?

a.BjameStroustnip

b.KenThompson

c.CharlesBabbage

d.AdaLovelaceAnswer:A

20.OneofthebiggestdifferencebetweenCandC++is:

a.Cisobject-oriented

b.C++isobject-oriented

c.AllC++programsarealsoCprograms

d.ConlyrunsonUNIXcomputersAnswer:B

21.intnumber;

a.isanoutputstatement

b.isaninputstatement

c.isavariabledeclaration

d.isaprogramAnswer:C

22.coul?“Howmanyitemswouldyouwant?\nM;

a.isanoutputstatement

b.isaninputstatement

c.isavariabledeclaration

d.isaprogramAnswer:A

23.cin?number;

Aisanoutputstatement

Bisaninputstatement

Cisavariabledeclaration

DisaprogramAnswer:B

23.Whatdoesthefollowingprinttothescreen?

cout?"HelloStudents/n^;

a.HelloStudents

b.helloStudents

c.HELLOSTUDENTS

d.HelloStudents/nAnswer:D

24.#include<iostream>

a.isavariabledeclaration

b.anexecutablestatement

c.anincludedirective

d.illegalcodeAnswer:C

25.Abyteconsistsofhowmanybits?

a.6

b.7

4

c.8

d.9

e.10Answer:C

26.Whatiswrongwiththefollowingstatement?

cout?“Hellotoeveryone\nn

a.coutshouldbecount

b.missingasemicolon

c.missinga”

d.missinga(Answer:B

Whatiswrongwiththefollowing(statement?

27.—批注LWS1J:28and27arethesame

cout?"Hellotoeveryone\n;

批注fMH2]:27and28aredifferent,

a.coutshouldbecount

27ismissingasemicolon,while28is

b.missingasemicolon

missingtheclosingdoublequote.

c.missinga”

d.missinga(Answer:C

28.C++isanexampleofa

a.Machinelanguage

b.High-levellanguage

c.Low-levellanguage

d.AssemblylanguageAnswer:B

29.RAMstandsfor

a.Readaccessmemory

b.Randomaccessmemory

c.Reallyatrociousmemory

d.AharddriveAnswer:B

TRUE/FALSE

1.GraceHopperdiscoveredthefirstdocumentedcomputerbug.

Answer:TRUE

2.Thefollowingstatementislegal:

cout?”Hello,mynameis

Answer:FALSE

3.YDUshouldwriteyourprogrambeforeyouwritethealgorithm.

Answer:FALSE

4.Itisconsideredbetterstyletoputthebraces({)}onseparatelines.

Answer:TRUE

5.Tliecompilerwillcatchallyourprogrammingmistakes.

Answer:FALSE

6.C++isalow-levellanguage.

Answer:FALSE

7.Mainmemoryholdsitsdataifthecomputeristurnedoff

Answer:FALSE

8.AnalgorithmisalwayswritteninC++Answer:FALSE

5

9.Thereare8bytesinonebit.

Answer:FALSE

10.Theprinterisanexampleofaninputdevice.

Answer:FALSE

TRUE/FALSE

1.Inthefollowingcodefragment,xhasthevalueof3.

intx=3;

ANSWER:TRUE

2.Thebodyofado-whileloopalwaysexecutesalleastonce.

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.?iscalledtheoperator.

ANSWER:insertion

2.Thebracesforaloopdefinetheoftheloop.

ANSWER:body

3.Aloopthatalwaysexecutestheloopbodyatleastonceisknownasa

loop.

ANSWER:do-while

4.intmyValue;iscalleda.

ANSWER:variabledeclaration

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

ANSWER:(x>=20IIx<=12)

6.Whatisthecorrectconditionalstatementtodetermineifxisbetween19and99?

ANSWER:(x>19&&xv99)

6

7.Eachtimealoopbodyexecutesisknownasan.

ANSWER:iteration

8.if-elsestatementsthatareinsideotherif-elsestatementsaresaidtobe.

ANSWER:nested

9.?isknownastheoperator.

ANSWER:extraction

10.Is?usedibrinputoroutput?

ANSWER:output

11.Thestreamthatisusedforinputfromthekeyboardiscalled.

ANSWER:cin

12.Thestreamthatisusedforoutputtothescreeniscalled.

ANSWER:cout

13.Writetheloopconditiontocontinueawhileloopaslongasxisnegative.

ANSWER:while(x<0)

14.Whenmustweusebracestodefinethebodyofacontitionalexpression?

ANSWER:Whentherearemultiplestatementsinthebody.

15.Inacompoundlogicaland(&&)expression,theevaluationoftheexpressionstopsj?nce批注[WS3]:trueonlyfor&&,notfor

oneofthetermsoftheexpressionisfalse.Thisisknownasevaluation.nwhereitlooksfortruenotfalse

ANSWER:short-circuitIevaluatiori亞4.....

l'批注[MH4]:ITaddedthe(&&o)tothe

question

MultipleChoice

1.Whichofthefollowingisavalididentifier?

a.3com

b.three_com

c.3_com

d.3-com

e.dollar$ANSWER:C

2.Whichofthefollowingisnotavalididentifer?

a.return

b.mylnt

c.mylnteger

d.total3ANSWER:A

3.Whatisthevalueofxafterthefollowingstatements?

intx,y,z;

y=10;

z=3;

x=y*z+3;

a.Garbage

b.60

30

7

d.33ANSWER:D

4.Whatisthevalueofxafterthefollowingstatements?

intx;

x=0;

x=x+30;

a.0

b.30

c.33

d.GarbageANSWER:B

5.Whatisthevalueofxafterthefollowingstatements?

intx;

x=x+30;

a.0

b.30

c.33

d.GarbageANSWER:D

6.Whatistheoutputofthefollowingcode?

floatvalue;

value=33.5;

cout?value?endl;

a.33.5

b.33

c.value

d.GarbageANSWER:A

7.Whatistheoutputofthefollowingcode?

floatvalue;

value=33.5;

cout?"value"?endl;

a.33.5

b.33

c.value

d.GarbageANSWER:C

8.Whatistheoutputofthefollowingcode?

cout?"Thisisa\V?endl;

a.Thisisa

b.Thisisa\

c.nothing,itisasyntaxerror

d.Thisisa\endlANSWER:B

9.Whichofthefollowinglinescorrectlyreadsiivaluefromthekeyboardandstoresitinthe

variablenamedmyFloat?

a.cin>>myFloat;

b.cin?myFloat;

c.cin?"myFloat";

d.cin?myFloat?endl;ANSWER:A

8

10.Anotherwaytowritethevalue3452211903is

a.3.452211903e09

b.3.452211903e-09

c.3.452211903x09

d.3452211903e09ANSWER:A

11.WhichofthefollowingstatementsisNOTlegal?

a.charch='b';

b.charch='O';

c.charch=65;

d.charch="ccM;ANSWER:D

12.Whatisthevalueofxafterthefollowingstatements?

floatx;

x=15/4;

a.3.75

b.4.0

c.3.0

d.60ANSWER:C

13.Whatisthevalueofxafterthefollowingstatements?

intx;

x=15/4;

a.15

b.3

c.4

d.3.75ANSWER:B

14.Whatisthevalueofxafterthefollowingstatements?

intx;

x=15%4;

a.15

b.4

c.3

d.3.75ANSWER:C

15.Whatisthevalueofxafterthefollowingstatement?

floatx;

x=3.0/4.0+3+2/5

a.5.75

b.5.75

c.1.75

d.3.75ANSWER:D

16.Whatisthevalueofxafterthefollowingstatement?

floatx;

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

a.5.75

b.5.75

c.1.75

9

d.3.75ANSWER: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.0ANSWER:C

18.Giventhefollowingcodefragmentandtheinputvalueof4.0,whatoutputisgenerated?

floattax;

floattotal;

cout?"enterthecostoftheitem\n";

cin?total;

if(total>=3.0)

(

tax=0.10;

cout?total+(total*tax)?endl;

)

else

(

cout?total?endl;

)

a.3

b.3.3

c.4.0

d.4.4ANSWER:D

19.Giventhefollowingcodefragmentandtheinputvalueof2.0,whatoutputisgenerated?

floattax;

floattotal;

cout?"enterthecostoftheitem\nH;

cin?total;

if(total>=3.0)

(

tax=0.10;

cout?total+(total*tax)?endl;

}

else

10

cout?total?endl;

)

a.2.2

b.2.0

c.3.1

d.4.4ANSWER:B

20.Ifxhasthevalueof3,yhasthevalueof-2,andwis10,isthefollowingconditiontrue

orfalse?

if(x<2&&w<y)

a.true

b.FalseANSWER:B

21.Whatisthecorrectwaytowritetheconditiony<x<z?

a.(y<x<z)

b.((y<x)&&z)

c.((y>x)II(y<z))

d.((y<x)&&(x<z))ANSWER:D

22.Giventhefollowingcodefragment,andaninputvalueof3,whatistheoutputthatis

generated?

intx;

cout?HEnteravalueVn1';

cin?x;

if(x=0)

(

cout?"xiszero\nH;

1

else

(

cout?nxisnotzero\n";

)

a.xiszero

b.xisnotzero

c.unabletodetenuine

d.xis3ANSWER:A(noteitisanbssignmenj!)批注[WS5]:Buttheansweristhe

23.Giventhefollowingcodefragment,andaninputvalueof5,whatistheoutput?sameasifyouused=insteadof=.

intx;Maybeaninputof0?

if(x<3)…

批注IMH6J:Ihadwittenthewrong

answer!Itwillalwaysprintout*xis

cout?"small\n";

zero,

1

else

if(x<4)

cout?"medium\n";

11

)

else

(

if(x<6)

(

cout?"lai^e\n";

}

else

(

cout?"giant\nn;

)

)

)

a.small

b.medium

c.large

d.GiantANSWER: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.GoodbyeANSWER:C

25.Executingoneormorestatementsoneormoretimesisknownas:

a.selection

b.iteration

c.sequence

d.AlgorithmANSWER:B

26.Giventhefollowingcodefragment,whatisthefinalvalueofy?

intx,y;

x=-1;

y=0;

while(x<=3)

(

y+=2;

x+=1;

(

a.2

b.10

6

12

d.8ANSWER舸批注[WS7]:Il,saninfiniteloop

27.Giventhefollowingcodefragment,whatisthefinalvalueofy?

批注IMH8]:Fixed.

intx,y;

x=-1;

y=0;

while(x<3)

(

y+=2;

x+=1;

)

a.2

b.10

c.6

d.8ANSWER:DL批注[WS9]:anotherinfiniteloop,

28.Whatistheoutputofthefollowingcodefragment?unlessImissedsomething

intx=0;

批注[MH10]:Fixed

while(x<5)

cout?x?endl;

X++:

cout?x?endl;

a.0

b.5

c.4

d.unabletodetermineANSWER:D(infiniteloop)

29.Whatisthefinalvalueofxafterthefollowingfragmentofcodeexecutes?

intx=0;

do

{

x++;

)while(x>0);

a.8

b.9

c.10

d.11

e.infiniteloopANSWER:同批注(WS11]:“infiniteloop"might

30.Giventhefollowingcodefragment,whichofthefollowingexpressionsisalwaystrue?beclearerthan“unknown”

intx;\

批注IMH12]:Fixed

cin?x;

a.if(x<3)

b.if(x=l)

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

d.if(x=1)ANSWER:D

13

TRUE/FALSE

1.Abooleanexpressionmayevaluatetomorethan2values

ANSWER:FALSE

2.Afunctionmayreturnabooleanvalue.

ANSWER:TRUE

3.Inanenumerateddatatype,differentconstantsmaynothavethesamevalue.

ANSWER:FALSE

4.Thecompileralwayspairsanelsewith

ANSWER:thenearestpreviousifnotalreadypairedwithanelse.

5.Allswitchstatementscanbeconvertedintonestedif-elsestatements

ANSWER:TRUE

6.Allnestedif-elsestatementscanbeconvertedintoswitchstatements.

ANSWER:FALSE

7.Abreakstatementinaswitchstopsyourprogram.

ANSWER:FALSE

8.Itisillegaltomakefunctioncallsinsideaswitchstatement.

ANSWER:FALSE

9.AsemicolonbyitselfisavalidC++statement.

ANSWER:TRUE

10.Thebreakstatementcausesallloopstoexit.

ANSWER:FALSE

ShortAnswer

1.Aexpressionisanexpressionthatcanbethoughtofasbeingtrueorfalse.

ANSWER:boolean

2.isatypewhosevaluesaredefinedbyalistofconstantsoftypeint.

ANSWER:enumerateddatatype

3.Thecodefollowingthecaseisexecutedifnoneoftheothercasesare

matchedinaswitchstatement.

ANSWER:default

4.Acompoundstatementthatcontainsvariabledeclarationsiscalleda.

ANSWER:block

5.Variablesdefinedinsideasetofbracesaresaidtobetothatblockofcode.

ANSWER:local

6.Eachrepetitionofaloopbodyiscalled.

ANSWER:aniteration

7.Aloopalwaysexecutestheloopbodyatleastonce,irregardlessoftheloop

condition.

ANSWER:do-while

8.Aswitchstatementvariablemustbe

ANSWER:aninteger,bool,charorenumeratedtype

9.Aloopthatiteratesonetoomanyoronetoofewtimesissaidtobe

ANSWER:offbyone

14

MultipleChoice

1.Whichbooleanoperationisdescribedbythefollowingtable?

ABOperation

TrueTrueTrue

TrueFalseTrue

FalseTrueTrue

FalseFalseFalse

a.or

b.and

c.not

d.noneoftheaboveANSWER:A

2.Whichbooleanoperationisdescribedbythefollowingtable?

ABOperation

TrueTrueTrue

TrueFalseFalse

FalseTrueFalse

FalseFalseFalse

a.or

b.and

c.not

d.noneoftheaboveANSWER:B

3.Whichofthefollowingsymbolshasthehighestprecedence?

a.++

b.II

c.&&

d.-ANSWER:A

4.Ifaprogramminglanguagedoesnotuseshort-circuitevaluation,whatistheoutputofthe

followingcodefragmentifthevalueofmylntis0?

intother=3,mylnt;

if(mylnt!=0&&other%mylnt!=0)

cout?"otherisodd\n";

else

cout?"otheriseven\n";

a.otheriseven

b.otherisodd

c.0

d.run-timeerror,nooutputANSWER:D

15

5.Whatisthevalueofthefollowingexpression?

(true&&(4/3II!(6)))

a.true

b.false

c.0

d.illegalsyntaxANSWER:A

6.ifxis0,whatisthevalueof(!x==0)?

a.false

b.true

c.unabletodetermine

d.AANSWER:A

7.Whichofthefollowingareequivalentto(!(x<15&&y>=3))?

a.(x>15&&y<=3)

b.(x>=15&&y<3)

c.(x>=15IIy<3)

d.(x>15IIy<3)

e.CandDANSWER:C

8.Whichofthefollowingbooleanexpressionsteststoseeifxisbetween2and15

(including2and15)?

a.(x<=15IIx>=2)

b.(2<=xllx<=15)

c.(x>=2&&x<=15)

d.(2<=x<=15)ANSWER:C

9.Giventhefollowingenumerateddatatypedefinition,whatisthevalueofSAT?

enummyl\pe{SUN,MON,TUE,WED,THUR,FRI,SAT,NumDays};

a.7

b.6

c.8

d.5

e.UnknownANSWER:b

10.Giventhefollowingenumerateddatatypedefinition,whatisthevalueofSAT?

enummylype{SUN=3,MON=l,TUE=3,WED,THUR,FRLSATNumDays};

a.7

b.6

c.8

d.5

e.Unknown

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論