Unlock access to all the studying documents.
View Full Document
Copyright Cengage Learning. Powered by Cognero.
1. A control structure alters the normal sequential flow of execution in a program.
2. The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.
3. In C++, both ! and != are relational operators.
4. The operators !, &&, and || are called relational operators.
Copyright Cengage Learning. Powered by Cognero.
5. The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.
6. Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.
7. In C++, && has a higher precedence than ||.
8. In C++, the operators != and == have the same order of precedence.
Copyright Cengage Learning. Powered by Cognero.
24. Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the following
expression: z = (y / x > 0) ? x : y;.
25. What is the value of x after the following statements execute?
int x;
x = (5 <= 3 && ‘A’ < ‘F’) ? 3 : 4
26. 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;
Copyright Cengage Learning. Powered by Cognero.
case ‘C’:
cout << “section 3″ <<endl;
break;
case ‘D’:
cout << “section 4″ <<endl;
break;
default:
cout << “section 5″ <<endl;
}
27. 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;