A control structure aleters the normal sequential flow of execution in a program
True
Conditional statements help incorporate decision making into programs
True
In C++, both ! and != are relational operators.
False
In C++, both "!", "&&" and "||" are relational operators.
False
False
The value of the expression 'a' < 'A' is true.
False
In C++, all relational operators are evaluated before logical operators.
False
. If a semicolon is placed after the expression in an if...else statement, the else statement is always executed.
False
The expression in the following if statement evaluates to true only if the value of score is 50. if (score = 50) grade = 'Z';
False
In a switch statement, every case must have a break.
False
The following while loop terminates when j > 20.
j = 0; while (j < 20) j++;
False
The number of iterations of a counter-controlled loop is known in advance.
True
A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value.
True
An EOF-controlled while loop is another name for a sentinel-controlled while loop.
False
Loop control variables are automatically initialized in a loop.
False
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
The control statements in the for loop include the initial statement, loop condition, and update statement.
True
A do...while loop is a post-test loop
True
The body of a do...while loop may not execute at all
False
Both while and for loops are pretest loops
True
Using functions greatly enhances the program’s readability because it reduces the complexity of the function main
True
To use a predefined function, the program must include the appropriate header file.
True
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
A value-returning function return only floating point values
False
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
True
When writing a function prototype, you do not have to specify the data type of each parameter.
False
The following return statement returns the value 10. return 10, 16
False
The function main is always compiled first, regardless of where in the program the function main is placed.
False
In a ____ control structure, the computer executes particular statements depending on some condition(s).
Selection
Which of the following is a relational operator?
==
Suppose that “x” is an int variable. Which of the following expressions always evaluates to true?
(x > 0) || (x <== 0)
Which of the following operators has the highest precedence
!
Which of the following expressions correctly determines that “x” is greater than 10 and less than 20
10 < x && x < 20
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
When one control statement is located within another, it is said to be ____.
Nested
Which of the following will cause a logical error if you are attempting to compare “x” to 5
if(x=5)
What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default: cout << "section 5" <<endl;
Section 5
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
What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl;
10
Assume all variables are properly declared. What is the output of the following C++ code? num = 100; while (num <= 150) num = num + 5; cout << num << endl;
155
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
A(n) ____-controlled while loop uses a bool variable to control the loop
Flag
A loop that continues to execute endlessly is called a(n) ____ loo
infinite
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;
cout << "Hello World"; ____ What is the output of the following C++ code? int j; for (j = 10; j <= 10; j++) cout << j << " "; cout << j << endl;
10 11
Which executes first in a do...while loop?
The statement
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
Which of the following loops is guaranteed to execute at least once
do...while loop
To use the predefined function “tolower”, the program must include the header file
cctype
The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl;
8.0
Given the following function prototype: int test(float, char); which of the following statements is valid
int u = test(5.0, '*');
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
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
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);
Given the function prototype: float test(int, int, int); which of the following statements is legal
cout << test(7, 14, 23);
Which of the following function prototypes is valid
int funcExp(int x, float v);
Given the following function prototype: int myFunc(int, int); which of the following statements is valid? Assume that all variables are properly declared.
cout << myFunc(myFunc(7, 8), 15);
The statement: return 8, 10; returns the value
10