3
Chapter 4 Self-Quiz True/False  Indicate whether th e statement is tru e or false.  ____ 1. Both selection and repet ition statements all ow the programmer to alter th e normal sequential flow of control.  ____ 2. The relationship 3 < 4 is always true, therefore the re lationship has a alue of !.  ____ 3. The logical operators "#$, %& and #%T are used to create more comple' relational e'pres sions.  ____ 4. The #%T operator i s a (inary operator .  ____ ). Te sts for equality of sin gle*precision and do u(le*precision alu es and aria(les usin g the relational operato r == are usually relia(le.  ____ +. The if-else statement directs the computer to select (etween two statements (ased on the result of a comparison.  ____ . "ll statements conta ined within a comp ound statement consti tute a single (loc- o f code.  ____ . if-else statements can not contain compound statements.  ____ /. Boolean alues true and false are represented (y the integer alues ! and 1 respectiely .  ____ 1!. 0 has always had a (uilt *in Boolean data ty pe with two Boolean alues , true and false.  ____ 11. if-else statements can not contain other if-else statements.  ____ 12. "n if-else chain is stopped once a true condition is found.  ____ 13. "n if-else chain can not (e continued indefinitely (y repeatedly ma-ing the last statement another if- else statement.  ____ 14. %nce an entry point has (e en located (y the switch statement further case ealuations will continue.  ____ 1). sing the assignment operator, =, in place of the relational operator, ==, is a commonly made 0  programming error. Multiple Choice  Identify the choice that best completes the statement or an swers the question .  ____ 1+. &elational e'pression s are also called ____ . a. options c. conditions  (. choices d. paths  ____ 1. The alue of a relational e' pression such as hours > 40 depends on the ____ stored in the aria(le hours. a. condition c. alue  (. sign d. relationship  ____ 1. ____ letters is essential in alpha(etiing names. a. 0omparing c. $eleting  (. 0apitaliing d. "dding  ____ 1/. any ____ num(ers cannot (e represented e'actly in ( inary form using a fini te num(er of (its. a. small c. integer  

CSC Quiz4 SelfQuiz

Embed Size (px)

Citation preview

Page 1: CSC Quiz4 SelfQuiz

7/21/2019 CSC Quiz4 SelfQuiz

http://slidepdf.com/reader/full/csc-quiz4-selfquiz 1/3

Chapter 4 Self-Quiz

True/False

 Indicate whether the statement is true or false.

 ____ 1. Both selection and repetition statements allow the programmer to alter the normal sequential flow of control.

 ____ 2. The relationship 3 < 4 is always true, therefore the relationship has a alue of !.

 ____ 3. The logical operators "#$, %& and #%T are used to create more comple' relational e'pressions.

 ____ 4. The #%T operator is a (inary operator.

 ____ ). Tests for equality of single*precision and dou(le*precision alues and aria(les using the relational operator

== are usually relia(le.

 ____ +. The if-else statement directs the computer to select (etween two statements (ased on the result of a

comparison.

 ____ . "ll statements contained within a compound statement constitute a single (loc- of code.

 ____ . if-else statements can not contain compound statements.

 ____ /. Boolean alues true and false are represented (y the integer alues ! and 1 respectiely.

 ____ 1!. 0 has always had a (uilt*in Boolean data type with two Boolean alues, true and false.

 ____ 11. if-else statements can not contain other if-else statements.

 ____ 12. "n if-else chain is stopped once a true condition is found.

 ____ 13. "n if-else chain can not (e continued indefinitely (y repeatedly ma-ing the last statement another if-

else statement.

 ____ 14. %nce an entry point has (een located (y the switch statement further case ealuations will continue. ____ 1). sing the assignment operator, =, in place of the relational operator, ==, is a commonly made 0

 programming error.

Multiple Choice

 Identify the choice that best completes the statement or answers the question.

 ____ 1+. &elational e'pressions are also called ____.

a. options c. conditions

 (. choices d. paths

 ____ 1. The alue of a relational e'pression such as hours > 40 depends on the ____ stored in the aria(le

hours.a. condition c. alue

 (. sign d. relationship

 ____ 1. ____ letters is essential in alpha(etiing names.

a. 0omparing c. $eleting

 (. 0apitaliing d. "dding

 ____ 1/. any ____ num(ers cannot (e represented e'actly in (inary form using a finite num(er of (its.

a. small c. integer  

Page 2: CSC Quiz4 SelfQuiz

7/21/2019 CSC Quiz4 SelfQuiz

http://slidepdf.com/reader/full/csc-quiz4-selfquiz 2/3

 (. large d. decimal

 ____ 2!. 5or single*precision and dou(le*precision operands, the general e'pression operand_1 == operand_2 

should (e replaced (y this condition6

a. operand_1 – operand_2 < EPSI!"

 (. a#s$operand_1 – operand_2% < EPSI!"

c. operand_2 – operand_1 < EPSI!"

d. operand_1 – operand_2 >= EPSI!"

 ____ 21. sing the a#s$% function requires including the ____ header file.

a. iostrea& c. c&ath

 (. s'ste& d. &ath

 ____ 22. "7n8 ____ statement is a sequence of single statements (etween (races.

a. Boolean c. compound

 (. conditional d. if-else

 ____ 23. 9f age is initialied to equal 1, the statement a(e == 40 has a alue of ____.

a. ! c. 1 (. 1 d. 3!

 ____ 24. 0 treats any nonero alue as ____.

a. true (. false

c. either true or false

d. #one of the a(oe, (ecause you cannot ma-e a general statement a(out this

 ____ 2). 9ncluding one or more if statements inside an e'isting if statement is called a ____ if statement.

a. compound c. nested

 (. comple' d. chain

 ____ 2+. 9n the a(sence of (races in an if-else statement, each else is associated with the ____ unpaired if.

a. ne't c. shortest

 (. last d. closest

 ____ 2. 9n a 0 program, statement indentation is ____ as far as the compiler is concerned.

a. required c. irreleant (. inalid d. standardied

 ____ 2. 9n an if-else chain, the final else is ____.

a. a default or catch*all case c. required

 (. recommended d. not used

 ____ 2/. ____ case la(els may (e contained within a switch statement.

a. p to 1 c. p to 1!!

 (. p to 1! d. "ny num(er of 

 ____ 3!. 9f #rea) statements are omitted from a switch statement, ____ cases following the matching case alue

are e'ecuted.

a. no c. all (. some d. two

Page 3: CSC Quiz4 SelfQuiz

7/21/2019 CSC Quiz4 SelfQuiz

http://slidepdf.com/reader/full/csc-quiz4-selfquiz 3/3

Chapter 4 Self-Quiz

Answer Section

TRUE/FALSE

1. "#:6 T ;T:6 1 &56 132. "#:6 5 ;T:6 1 &56 13

3. "#:6 T ;T:6 1 &56 13/

4. "#:6 5 ;T:6 1 &56 14!

). "#:6 5 ;T:6 1 &56 142

+. "#:6 T ;T:6 1 &56 143

. "#:6 T ;T:6 1 &56 14

. "#:6 5 ;T:6 1 &56 14/

/. "#:6 5 ;T:6 1 &56 1)3

1!. "#:6 5 ;T:6 1 &56 1)3

11. "#:6 5 ;T:6 1 &56 1)

12. "#:6 T ;T:6 1 &56 1)/13. "#:6 5 ;T:6 1 &56 1+!

14. "#:6 5 ;T:6 1 &56 1+/

1). "#:6 T ;T:6 1 &56 13

MULT!LE C"#CE

1+. "#:6 0 ;T:6 1 &56 13

1. "#:6 0 ;T:6 1 &56 13/

1. "#:6 " ;T:6 1 &56 13/

1/. "#:6 $ ;T:6 1 &56 142

2!. "#:6 B ;T:6 1 &56 142

21. "#:6 0 ;T:6 1 &56 142

22. "#:6 0 ;T:6 1 &56 14+

23. "#:6 " ;T:6 1 &56 1)1*1)2

24. "#:6 " ;T:6 1 &56 1)2

2). "#:6 0 ;T:6 1 &56 1)

2+. "#:6 $ ;T:6 1 &56 1)/

2. "#:6 0 ;T:6 1 &56 1)/

2. "#:6 " ;T:6 1 &56 1)/

2/. "#:6 $ ;T:6 1 &56 1+

3!. "#:6 0 ;T:6 1 &56 1+/