sample test 1 - 1. What does the following statement...

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

View Full Document Right Arrow Icon
1. What does the following statement display? int a = 5; int b = 10; if (!(a*2 <= b)) cout << a*2 << " is less than or equal to " << b; else cout << a*2 << " is greater than or equal to " << b; a. 10 is less than or equal to b b. A*2 is less than or equal to b c. 10 is greater than or equal to 10 d. a*2 is greater than or equal to 10 e. 5 is greater than or equal to 10 f. 10 is less than or equal to 10 g. a*2 is greater than or equal to b h. 5 is less than or equal to 10 i. a*2 is greater than or equal to 10 j. nothing will be printed 2. What is the effect of the following code fragment? (Assume no run-time errors). int num1 = 2; int num2; cin >> num2; if (num2 % num1 == 0) cout << "first option" << endl; else cout << "second option" << endl; a. displays first option if num1 and num2 are equal, and second option otherwise. b. displays first option if num1 and num2 are not equal, and second option otherwise. c. displays first option if num1 and num2 are not equal to 0, and second option otherwise. d. assigns the character '%' to the variable num2 if num1 is 0, and displays first option e. displays first option if num1 and num2 are equal to 0, and second option otherwise. f. displays first option if an even number is entered as input, and second option if an odd number is entered as input. g. displays first option if an odd number is entered as input, and second option if an even number is entered as input.
Background image of page 1

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

View Full DocumentRight Arrow Icon
3. Which C++ condition is TRUE if and only if the value of x is not between 0 and 100 (inclusive)? a. b. 0 <= x <= 100 c. d. 0 <= x | x <= 100 e. f. 0 <= x || x <= 100 g. -1 < x < 101 h. i. 0 < x < 100 j. x < 0 || x > 100 4. What do the following statements display, if the value of the input is 0? cin >> color; switch (color) { case 0: case 1: cout << "red "; case 2: cout << "blue "; case 3: cout << "green "; case 4: cout << "yellow "; } cout << endl; a. green b. purple c. blue d. red blue green yellow e. black f. no output g. blue green yellow h. red blue i. red
Background image of page 2
j. yellow 5. The __________ contains the arithmetic/logic unit (ALU) of the computer. (10) integrated circuit a. double b. disk c. silicate d. nibble e. central processing unit f. bank g. byte h. word i. bit j. integrated circuit 6. How many times is the loop of the for statement executed in the following segment of code? int x = 10, y = 0; for (int i=10; i<=50; i=i+1) { cin >> x; y = y + x; } a. zero b. 39 times c. 51 times d. until a number larger than 10 is entered e. twice f. 49 times g. Once h. 40 times i. 41 times
Background image of page 3

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

View Full DocumentRight Arrow Icon
j. 50 times 7. Which statements are true? [select the best answer] a. The value of the expression (15 < 20 || 20 >= 20) is TRUE. b.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/23/2009 for the course ENGE 2314 taught by Professor Tdwalker during the Spring '07 term at Virginia Tech.

Page1 / 18

sample test 1 - 1. What does the following statement...

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

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