A control structure aleters the normal sequential flow of execution in a program
True
2
New cards
Conditional statements help incorporate decision making into programs
True
3
New cards
In C++, both ! and != are relational operators.
False
4
New cards
In C++, both "!", "&&" and "||" are relational operators.
False
5
New cards
The expression (x >= 0 && x
False
6
New cards
The value of the expression 'a' < 'A' is true.
False
7
New cards
In C++, all relational operators are evaluated before logical operators.
False
8
New cards
. If a semicolon is placed after the expression in an if...else statement, the else statement is always executed.
False
9
New cards
The expression in the following if statement evaluates to true only if the value of score is 50. if (score = 50) grade = 'Z';
False
10
New cards
In a switch statement, every case must have a break.
False
11
New cards
The following while loop terminates when j > 20.
j = 0; while (j < 20) j++;
False
12
New cards
The number of iterations of a counter-controlled loop is known in advance.
True
13
New cards
A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value.
True
14
New cards
An EOF-controlled while loop is another name for a sentinel-controlled while loop.
False
15
New cards
Loop control variables are automatically initialized in a loop.
False
16
New cards
In an EOF-controlled loop if the program reads any faulty data (such as a char value into an int variable), the input stream variable returns the value false.
True
17
New cards
The control statements in the for loop include the initial statement, loop condition, and update statement.
True
18
New cards
A do...while loop is a post-test loop
True
19
New cards
The body of a do...while loop may not execute at all
False
20
New cards
Both while and for loops are pretest loops
True
21
New cards
Using functions greatly enhances the program’s readability because it reduces the complexity of the function main
True
22
New cards
To use a predefined function, the program must include the appropriate header file.
True
23
New cards
To use a predefined value-returning function in a program, the programmer only needs to know the appropriate header file, the name of the function, and the type of the value returned by the function.
False
24
New cards
A value-returning function return only floating point values
False
25
New cards
The function heading: int funcAlpha(float u, char v, int g) in a C++ program will cause a syntax error because the function return type is int and so the first parameter, “u”, must be of type int.
False
26
New cards
The statement return static_cast(x + 5); where “x” is an int variable, returns a char value in a valuereturning function
True
27
New cards
When writing a function prototype, you do not have to specify the data type of each parameter.
False
28
New cards
The following return statement returns the value 10. return 10, 16
False
29
New cards
The function main is always compiled first, regardless of where in the program the function main is placed.
False
30
New cards
In a ____ control structure, the computer executes particular statements depending on some condition(s).
Selection
31
New cards
Which of the following is a relational operator?
==
32
New cards
Suppose that “x” is an int variable. Which of the following expressions always evaluates to true?
(x > 0) || (x
33
New cards
Which of the following operators has the highest precedence
!
34
New cards
Which of the following expressions correctly determines that “x” is greater than 10 and less than 20
10 < x && x < 20
35
New cards
What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y – x; cout << x << " " << y << " " << z << endl;
35 45 10
36
New cards
When one control statement is located within another, it is said to be ____.
Nested
37
New cards
Which of the following will cause a logical error if you are attempting to compare “x” to 5
if(x=5)
38
New cards
What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <
Section 5
39
New cards
What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y – 3; } cout << y << endl;
2
40
New cards
What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl;
10
41
New cards
Assume all variables are properly declared. What is the output of the following C++ code? num = 100; while (num
155
42
New cards
Suppose “sum” and “num” are int variables, and the input is: 18 25 61 6 -1. What is the output of the following code? sum = 0; cin >> num; while (num != -1) { sum = sum + num; cin >> num; } cout << sum << endl;
110
43
New cards
A(n) ____-controlled while loop uses a bool variable to control the loop
Flag
44
New cards
A loop that continues to execute endlessly is called a(n) ____ loo
infinite
45
New cards
Which of the following is the initial statement in the following for loop? (Assume that all variables are properly declared.) int i; for (i = 1; i < 20; i++) cout << "Hello World"; cout << "!" << endl
i = 1;
46
New cards
cout << "Hello World"; ____ What is the output of the following C++ code? int j; for (j = 10; j
10 11
47
New cards
Which executes first in a do...while loop?
The statement
48
New cards
What is the value of x after the following statements execute? int x = 5; int y = 30; do x = x * 2; while (x < y);
40
49
New cards
Which of the following loops is guaranteed to execute at least once
do...while loop
50
New cards
To use the predefined function “tolower”, the program must include the header file
cctype
51
New cards
The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl;
8.0
52
New cards
Given the following function prototype: int test(float, char); which of the following statements is valid
int u = test(5.0, '*');
53
New cards
A variable listed in a function call is known as a(n) ____ parameter. A variable list in a header is known as a(n) ____ parameter.
actual; formal
54
New cards
Given the following function: int next(int x) { return (x + 1); } what is the output of the following statement? cout << next(next(5)) << endl;
7
55
New cards
Given the following function prototype: double tryMe(double, double);, which of the following statements is valid? Assume that all variables are properly declared.
cout << tryMe(2.0, 3.0);
56
New cards
Given the function prototype: float test(int, int, int); which of the following statements is legal
cout << test(7, 14, 23);
57
New cards
Which of the following function prototypes is valid
int funcExp(int x, float v);
58
New cards
Given the following function prototype: int myFunc(int, int); which of the following statements is valid? Assume that all variables are properly declared.