1/29
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
A piece of data is called logical if it conveys the idea of true or false.
True
C programmers use other types, such as integers, to represent logical data.
True
If a data value is zero it is considered false, but any non-zero value is considered true.
True
The logical AND (&&) operator is only true when both operands are true.
True
The logical OR (||) operator is true only when exactly one of its operands is true.
False - true if at least one is true (or both)
The AND and OR operator share the same level of operator precedence.
False - AND has higher precedence
The short-circuit method of evaluating logical expressions will stop evaluating the current expression as soon as the result can be determined.
True
The complement of the equal operator is the not equal operator.
True
The complement of the less than operator is the greater than operator.
False
When attempting to print the result of a logical expression that is true as an integer the result will always be 1.
True
The logical expression of an if...else construct must be enclosed in parentheses.
True
There is no semi-colon that follows the logical expression of an if...else construct.
True
The statements found inside of an if...else may be any statement, including another if...else construct.
True
The expressions if(a != 0) and if(!a) are complements.
True
The expressions if(a == 0) and if(a) are complements.
True
The dangling else logical error can be corrected by indenting the if and else the same number of spaces.
False - program automatically pairs dangling else to the most recent if statement, so braces are needed to specify the true meaning (indenting doesn’t help)
The conditional expression has three operands and a two-token operator.
True - tokens are ? and :
Conditional expressions cannot be nested as the resulting code becomes too complex.
False - they CAN be nested, but not recommended (because too complex)
3 && -3 && 10 && -10
True
3 || -3 || 10 || -10
True
3 || 6 && 0
True - && expression evaluated first
3 == 4 || 6 || 8
True
3 == 3 && -1 && 1
True
6 % 2 || 7 % 2
True
The following two logical expressions are equivalent for all integer (int) values of x:
!(x < 10) and x >= 10
True
The following two logical expressions are equivalent for all non-negative integer (int) values of x:
x % 2 and x % 2 != 0
True
The complement of
x > 0 && x < 10 || y + 2 == 0
is
x <= 0 || x >= 10 && y + 2 != 0
False I think - precedence?
The compiler will issue a warning when an assignment operator rather than the equality operator is used as the logical expression of an if condition.
True (probably)
It is a course standard to make use of { and } with all if-else constructs.
True
It is a course standard to indent all code within the body of a selection construct two additional spaces.
True