Cccc

Page 1

Q1: MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) What does the term hardware refer to? A) the logical flow of instructions B) the way a computer's storage space is organized C) the physical components that a computer is made of D) the relative difficulty of programming E) None of these Answer: C 2) Programmer-defined names of memory locations that may hold data are: A) operands B) operators C) syntax D) variables E) None of these. Answer: D 3) Words that have a special meaning and may be used only for their intended purpose are known as: A) key words B) syntax C) programmer defined words D) operators E) None of these Answer: A 4) Mistakes that cause a running program to produce incorrect results are called: A) syntax errors B) linker errors C) logic errors D) compiler errors E) None of these Answer: C 5) Computer programs are also known as: A) hardware B) firmware C) silverware D) software E) None of these Answer: D 6) In a C++ program, two slash marks ( // ) indicate: A) the beginning of a comment B) the end of the program C) the beginning of a block of code D) the end of a statement E) None of these Answer: A 1


7) What is the modulus operator? A) % B) *

C) ||

D) +

E) &

D) short

E) char

Answer: A 8) Which data type typically requires only one byte of storage? A) float B) double C) int Answer: E 9) How would you consolidate the following declaration statements into one statement? int x = 7; int y = 16; int z = 28;

A) int x = 7 y = 16 z = 28; B) int x = 7; y = 16; z = 28; C) int x, y, z = 7, 16, 28 D) int x = 7, y = 16, z = 28; E) None of these will work. Answer: D 10) Which one of the following would be an illegal variable name? A) dayOfWeek B) June1997 C) 3dGraph D) itemsorderedforthemonth E) _employee_num Answer: C 11) This control sequence is used to skip over to the next horizontal tab stop. A) \n B) \t C) \h D) \'

E) \a

Answer: B 12) Every complete C++ program must have a __________. A) symbolic constant B) cout statement C) function named main D) comment E) preprocessor directive Answer: C 13) Which character signifies the beginning of an escape sequence? A) \ B) { C) /

D) #

E) //

Answer: A 14) Which escape sequence causes the cursor to move to the beginning of the current line? A) \b B) \n C) \r D) \t Answer: C

2

E) \a


15) This is used to mark the end of a complete C++ programming statement. A) pound sign B) semicolon C) void D) data type E) None of these Answer: B 16) What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl;

A) 12 B) 72 C) 15 D) 63 E) None of these Answer: A 17) You must have a ________ for every variable you intend to use in a program. A) constant B) purpose C) definition D) comment E) None of these Answer: C 18) Of the following, which is a valid C++ identifier? A) ___department B) June1997 C) _employee_number D) myExtraLongVariableName E) All of the above are valid identifiers. Answer: E 19) The ________ is/are used to display information on the computer's screen. A) opening and closing quotation marks B) backslash C) opening and closing braces D) cout object E) None of these Answer: D 20) For every opening brace in a C++ program, there must be a: A) string literal B) closing brace C) function D) variable E) None of these Answer: B

3


21) Look at the following program and answer the question that follows it. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

// This program displays my gross wages. // I worked 40 hours and I make $20.00 per hour. # include <iostream> using namespace std; int main( ) { int hours; double payRate, grossPay;

}

hours = 40; payRate = 20.0; grossPay = hours * payRate; cout << "My gross pay is $" << grossPay << endl; return 0;

Which line(s) in this program cause output to be displayed on the screen? A) 14 B) 13 C) 15 D) 13 and 14

E) 8 and 9

Answer: A 22) What will the following code display? cout << "Monday"; cout << "Tuesday"; cout << "Wednesday";

A) "Monday" "Tuesday" "Wednesday" C) Monday Tuesday Wednesday

B) Monday Tuesday Wednesday D) MondayTuesdayWednesday

Answer: D 23) What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl;

A) xyz

B) 012

C) 0 1 2

Answer: B

4

D) 0 1 2


24) What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;

A) Four score and seven years ago

B) Four score and seven years ago D) Four score and seven years ago

C) Four score and seven years ago Answer: B 25) What will the following code display? int number = 7; cout << "The number is " << "number" << endl;

A) The number is 7 C) The number is number

B) The number is 0 D) The number is7

Answer: C 26) Which of the following defines a double-precision floating point variable named payCheck? A) Double payCheck; B) float payCheck; C) payCheck double; D) double payCheck; Answer: D 27) What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl;

A) Four score and seven yearsago

B) Four score and seven/nyearsago

C) Four score and seven years ago

D) Four score and seven yearsago

Answer: B

5


28) Which line in the following program will cause a compiler error? 1 2 3 4 5 6 7 8 9 10

#include <iostream> using namespace std; int main( ) { const int MY_VAL = 77; MY_VAL = 99; cout << MY_VAL << endl; return 0; }

A) 9

B) 8

C) 7

D) 6

Answer: C 29) Which line in the following program will cause a compiler error? 1 2 3 4 5 6 7 8 9 10

#include <iostream> using namespace std; int main( ) { const int MY_VAL; MY_VAL = 77; cout << MY_VAL << endl; return 0; }

A) 9

B) 8

C) 6

D) 7

Answer: C 30) What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3;

A) 15

B) 30

C) 2

D) 3

C) x * 2;

D) None of these

Answer: A 31) Which statement is equivalent to the following? x = x * 2;

A) x *= 2;

B) x = x * x;

Answer: A

6


32) The statement cin >> setw(10) >> str; will read up to this many characters into str. A) nine B) eleven C) eight D) ten E) None of these

Answer: A 33) Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed? x = -3 + 4 % 6 / 5;

A) 2 B) 0 C) -3 D) 1 E) None of these Answer: C 34) When the final value of an expression is assigned to a variable, it will be converted to: A) the largest C++ data type B) the data type of the variable C) the data type of the expression D) the smallest C++ data type E) None of these Answer: B 35) In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2 ;

A) 10 / 2

B) 3 * 2

C) 6 - 3

D) 7 - 10

E) 2 + 7

D) cstring

E) iomanip

Answer: B 36) The function, pow(x, 5.0), requires this header file. A) iostream B) cstdlib C) cmath Answer: C 37) This function tells the cin object to skip one or more characters in the keyboard buffer. A) cin.skip B) cin.jump C) cin.hop D) cin.ignore E) None of these Answer: D

7


38) What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4); A) .275229 B) .3 C) 3.3 D) 0 E) None of these

Answer: D 39) When this operator is used with string operands it concatenates them, or joins them together. A) & B) % C) * D) + E) None of these Answer: D 40) ________ reads a line of input, including leading and embedded spaces, and stores it in a string object. A) cin.get B) getline C) get D) cin.getline E) None of these Answer: B 41) The ________ operator always follows the cin object, and the ________ operator follows the cout object. A) conditional, binary B) binary, unary C) >>, << D) <<, >> E) None of these Answer: C 42) What will the value of x be after the following statements execute? int x; x = 18 % 4;

A) 4

B) 0.45

C) 2

D) unknown

Answer: C 43) What will the value of x be after the following statements execute? int x; x = 18.0 / 4;

A) 0

B) 4.5

C) 4

Answer: B 8

D) unknown


44) What will the value of x be after the following statements execute? int x; x = 18 / 4;

A) 4

B) 0

C) 4.5

Answer: A

9

D) unknown


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.