

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A worksheet for students learning c++ with exercises on boolean expressions and selection statements. It includes true or false questions, explanations for false answers, and instructions for evaluating complex boolean expressions. The document also includes a solution key for the exercises.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CSCI261 Lecture Questions
C++ Boolean Expressions and Selection Statements
This worksheet is for your use during and after lecture. It will not be collected or graded, but I think you will find it a useful tool as you learn C++ and study for the exams. Explain all false answers for the “True or False” questions; in general, show enough work and provide enough explanation so that this sheet is a useful pre-exam review. I will be happy to review your answers with you during office-hours, via Email, or instant messaging.
A is equal to B is not equal to C is less than D is greater than E is less than or equal to F is greater than or equal to G logical inverse or NOT H logical intersection or AND I logical union or OR J Not a C++ relational or Boolean operator.
Solution: c is buggy, the programmer wants to write (1<=3) && (3<=1). This is a contrived example, Usually this type of error is written in code like this: 1 <= x <= 3 , where the programmer wants to test x ∈ [ 1 , 3 ]. But for what values of x is this true or false? Does it really test what the programmer intended? Also, note that b and ?? are evaluated the same, since the parenthesis in b do not change the order of operations.
Solution: B
Solution: They select a sequence of instructions for the CPU to follow, also known as the code path.
CSCI261 Lecture Questions
C++ Boolean Expressions and Selection Statements
Line # x y z k m j
Solution: m=0. k= j=
Page 2