Upload
mohamed-metwalli
View
218
Download
0
Embed Size (px)
DESCRIPTION
Â
Citation preview
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 instructionsB) the way a computer's storage space is organizedC) the physical components that a computer is made ofD) the relative difficulty of programmingE) None of these
Answer: C
2) Programmer-defined names of memory locations that may hold data are:A) operandsB) operatorsC) syntaxD) variablesE) 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 wordsB) syntaxC) programmer defined wordsD) operatorsE) None of these
Answer: A
4) Mistakes that cause a running program to produce incorrect results are called:A) syntax errorsB) linker errorsC) logic errorsD) compiler errorsE) None of these
Answer: C
5) Computer programs are also known as:A) hardwareB) firmwareC) silverwareD) softwareE) None of these
Answer: D
6) In a C++ program, two slash marks ( // ) indicate:A) the beginning of a commentB) the end of the programC) the beginning of a block of codeD) the end of a statementE) None of these
Answer: A
1
7) What is the modulus operator?A) % B) * C) || D) + E) &
Answer: A
8) Which data type typically requires only one byte of storage?A) float B) double C) int D) short E) char
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, 28D) 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) dayOfWeekB) June1997C) 3dGraphD) itemsorderedforthemonthE) _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 constantB) cout statementC) function named mainD) commentE) 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 E) \a
Answer: C
2
15) This is used to mark the end of a complete C++ programming statement.A) pound signB) semicolonC) voidD) data typeE) None of these
Answer: B
16) What is the output of the following statement?
cout << 4 * (15 / (1 + 3)) << endl;
A) 12B) 72C) 15D) 63E) None of these
Answer: A
17) You must have a ________ for every variable you intend to use in a program.A) constantB) purposeC) definitionD) commentE) None of these
Answer: C
18) Of the following, which is a valid C++ identifier?A) ___departmentB) June1997C) _employee_numberD) myExtraLongVariableNameE) 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 marksB) backslashC) opening and closing bracesD) cout objectE) None of these
Answer: D
20) For every opening brace in a C++ program, there must be a:A) string literalB) closing braceC) functionD) variableE) None of these
Answer: B
3
21) Look at the following program and answer the question that follows it.
1 // This program displays my gross wages.2 // I worked 40 hours and I make $20.00 per hour.3 # include <iostream>
4 using namespace std;56 int main( )7 {8 int hours;9 double payRate, grossPay;1011 hours = 40;12 payRate = 20.0;13 grossPay = hours * payRate;14 cout << "My gross pay is $" << grossPay << endl;15 return 0;16 }
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"
B) MondayTuesdayWednesday
C) 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) 012
D) 0 1 2
Answer: B
4
24) What will the following code display?
cout << "Four\n" << "score\n";cout << "and" << "\nseven";cout << "\nyears" << " ago" << endl;
A) Four scoreand sevenyears ago
B) Fourscoreandsevenyears ago
C) Fourscoreand sevenyears ago
D) Four score and sevenyears ago
Answer: B
25) What will the following code display?
int number = 7;cout << "The number is " << "number" << endl;
A) The number is 7 B) The number is 0C) The number is number 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 sevenyearsago
B) Four score and seven/nyearsago
C) Four score and sevenyears ago
D) Fourscoreandsevenyearsago
Answer: B
5
28) Which line in the following program will cause a compiler error?
1 #include <iostream>
2 using namespace std;34 int main( )5 {6 const int MY_VAL = 77;7 MY_VAL = 99;8 cout << MY_VAL << endl;9 return 0;10 }
A) 9 B) 8 C) 7 D) 6Answer: C
29) Which line in the following program will cause a compiler error?
1 #include <iostream>
2 using namespace std;34 int main( )5 {6 const int MY_VAL;7 MY_VAL = 77;8 cout << MY_VAL << endl;9 return 0;10 }
A) 9 B) 8 C) 6 D) 7Answer: 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) 3Answer: A
31) Which statement is equivalent to the following?
x = x * 2;
A) x *= 2; B) x = x * x; C) x * 2; D) None of theseAnswer: A
6
32) The statement
cin >> setw(10) >> str;
will read up to this many characters into str.A) nineB) elevenC) eightD) tenE) None of these
Answer: A
33) Assume that x is an int variable. What value is assigned to x after the following assignment statement isexecuted?
x = -3 + 4 % 6 / 5;
A) 2B) 0C) -3D) 1E) 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 typeB) the data type of the variableC) the data type of the expressionD) the smallest C++ data typeE) 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 + 7Answer: B
36) The function, pow(x, 5.0), requires this header file.A) iostream B) cstdlib C) cmath D) cstring E) iomanip
Answer: C
37) This function tells the cin object to skip one or more characters in the keyboard buffer.A) cin.skipB) cin.jumpC) cin.hopD) cin.ignoreE) 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) .275229B) .3C) 3.3D) 0E) 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 theseAnswer: D
40) ________ reads a line of input, including leading and embedded spaces, and stores it in a string object.A) cin.getB) getlineC) getD) cin.getlineE) None of these
Answer: B
41) The ________ operator always follows the cin object, and the ________ operator follows the cout object.A) conditional, binaryB) binary, unaryC) >>, <<
D) <<, >>
E) None of theseAnswer: 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) unknownAnswer: 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 D) unknownAnswer: B
8
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 D) unknownAnswer: A
9