{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

sample test 1

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

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

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.

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

View Full Document
3. Which C++ condition is TRUE if and only if the value of x is not between 0 and 100 (inclusive)? 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
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; } h. 40 times i. 41 times

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

View Full Document
j. 50 times 7. Which statements are true? [select the best answer] h. All the above statements are false.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

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

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

View Full Document
Ask a homework question - tutors are online