Chapter02-SampleQuestions

Chapter02-SampleQuestions - Sample Multiple Choice...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
BCEE 231 Chapter 2 - Sample questions 1 Sample Multiple Choice Questions – Chapter 2 In Part 1: Consider carefully each question, and select the best answer In Part 2: Write the answer number and its reason or justification. Part 1 The situation In relation to the described situation: 1. The following code segment has a syntax error: if(Volume) notice(" Volume is not zero:", Volume); A = A/Volume; } The syntax error is caused by: a) else-clause is missing b) ‘if’ is in lower case c) ‘Volume’ is undefined d) variable ‘A’ appears in both left and right hand side of the assignment expression e) unbalanced parentheses or braces 2. Consider the following code segment: if(Pressure) { notice(" Volume is not zero:", Volume); A = B/Pressure; } The main purpose of the if-statement is: a) to test if ‘Pressure’ is positive b) to test if ‘Pressure’ is zero c) to test if ‘Pressure’ is negative d) to test if ‘Pressure’ is non-zero e) to test if ‘Pressure’ is greater than zero 3. Consider the following program: main() { A = 1; B = 10; C = 100; if(B >= (C = 20)) { A = C/B; } else { A = 3; C = 30; } print(^, A, B, C); } The program produces the following output: a) 1 10 100 b) 3 10 20 c) 10 10 100 d) 3 10 30 ______________ e) None of the above 4. Consider the following code segment: E1 = ((a=2+4) < a || a > 0); E2 = ((b=5) == b && b <= 0); This code segment will give the following values for a, b, E1 and E2: a) a = 6, b = 5, E1 = 1, E2 = 0 b) a = 6, b = 5, E1 = 1, E2 = 1 c) a = 6, b = 5, E1 = 0, E2 = 0 d) a = 0, b = 1, E1 = 0, E2 = 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
BCEE 231 Chapter 2 - Sample questions 2 _____________ e) None of the above 5. Given the following program: main () { Sum = 1; I = 3; do { Sum = Sum + I; print (^, I,Sum); I=I-1; } while (I); print (^" Final sum = ", Sum); } ONE of the following statements about the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2010 for the course ENGR 235 taught by Professor Yy during the Spring '10 term at Concordia Canada.

Page1 / 5

Chapter02-SampleQuestions - Sample Multiple Choice...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online