Test 2 Flashcards
T or F? In an && operation, if the first operand is true the result is true.
False
T or F? In an && operation, if the first operand is false the result is false.
True
T or F? In an || operation, if the first operand is true the result is true.
True
T or F? In an && operation, if both operands are true the result is true.
True
T or F? In an || operation, if the first operand is false the result is false.
False
T or F? In the evaluation of a logical expression, ! has priority over the && and || operations.
True
T or F? In the evaluation of a logical expression, parentheses have higher priority than logical operators.
True
T or F? In the evaluation of a logical expression, arithmetic operators have higher priority than relational and logical operators.
True
T or F? In the evaluation of a relational expression, relational operators have lower priority than logical operators.
False
Given the following logical values, expr1 =t true, expr2 = false, expr3 = true, expr4 = false, evaluate the following logical expressions. expr1 && expr2 || expr3
True
Given the following logical values, expr1 =t true, expr2 = false, expr3 = true, expr4 = false, evaluate the following logical expressions. expr1 || expr2 && expr3
True
Given the following logical values, expr1 =t true, expr2 = false, expr3 = true, expr4 = false, evaluate the following logical expressions. !expr2 && expr1 || expr4
True
Given the following logical values, expr1 =t true, expr2 = false, expr3 = true, expr4 = false, evaluate the following logical expressions. !expr2 && (expr1 || expr3)
True
Given the following logical values, expr1 =t true, expr2 = false, expr3 = true, expr4 = false, evaluate the following logical expressions. !(expr1 && expr3) || expr1
True
Given the following values for the variables, a =10, b = 5, c = 12, and d = 8, evaluate the following relational and logical expressions. a > b || b < c && d > b
True
Given the following values for the variables, a =10, b = 5, c = 12, and d = 8, evaluate the following relational and logical expressions. !(a < b && c >d) || c < d
True
Given the following values for the variables, a =10, b = 5, c = 12, and d = 8, evaluate the following relational and logical expressions. a <= b || !b < c && d > a
False
Given the following values for the variables, a =10, b = 5, c = 12, and d = 8, evaluate the following relational and logical expressions. a > c && !d < c || (a > b && b
True
Given the following values for the variables, a = 10, b = 15, c = 10, and d = 25, evaluate the following relational expressions. a >= c
True
Given the following values for the variables, a = 10, b = 15, c = 10, and d = 25, evaluate the following relational expressions. b < d
True
Given the following values for the variables, a = 10, b = 15, c = 10, and d = 25, evaluate the following relational expressions. a * b / 2 >= c + d / 5 + 2
True
Given the following values for the variables, a = 10, b = 15, c = 10, and d = 25, evaluate the following relational expressions. a - b <= c + d - 4
True
Write code for the following selection structure flowchart.
if(c1)
{
if(c2)
stmt3;
else
stmt2;
}
else
stmt1;
T/F? A relational expression assigns values to the operands, which make it true.
False