ch4-5

Cards (52)

  • In an if/else if statement, the conditions are tested until one is found to be true. The conditionally executed statement(s) are executed and the program exits the if/else if statement. In a series of if statements, all of the if statements execute and test their conditions because they are not connected
  • The trailing else provides code that is executed when none of the conditions inthe if/else if statement are true
  • A flag is a Boolean variable signaling that some condition exists in the program.When the flag is set to false it indicates the condition does not yet exist. Whenthe flag is set to true it indicates that the condition does exist.
  • Yes. The if statement can test any value that yields a Boolean value (true orfalse) or a numeric value. When testing a numeric expression, a nonzeronumeric value is considered true, and the value 0 is considered false.
  • t takes two expressions as operands and creates a single expression that is trueonly when both subexpressions are true.
  • It takes two expressions as operands and creates a single expression that is truewhen either of the subexpressions are true
  • relational operators called relational cuz they test for specific relationships between items. The relationships aregreater-than, less-than, equal-to, greater-than or equal-to, less-than or equal-to,and not equal-to
  • Why do most programmers indent the conditionally executed statements in a decision
    structure? It visually sets the condition statements apart from the surrounding code. This is so you can easily identify the code that is conditionally-executed.
  • An expression using the greater-than, less-than, greater-than-or-equal to, less-than-or equal-to,equal, or not-equal to operator is called a(n) relational expression.
  • relational expression is either True or False
  • The value of a relational expression is 0 if the expression is False or 1 if theexpression is True
  • The if statement regards an expression with the value 0 as False
  • The if statement regards an expression with a nonzero value as True
  • For an if statement to conditionally execute a group of statements, the statements must beenclosed in a set of braces.
  • In an if/else statement, the if part executes its statement or block if the expression is True, and the else part executes its statement or block if the expression is False.
  • The trailing else in an if/else if statement has a similar purpose as the default section ofa switch statement
  • The if/else if statement is actually a form of the nested if statement
  • If the sub-expression on the left of the && logical operator is false, the right sub-expression is not checked.
  • If the sub-expression on the left of the || logical operator is true, the right sub-expression is not checked.
  • The ! logical operator has higher precedence than the other logical operators
  • The logical operators have left to right associativity.
  • The && logical operator works best when testing a number to determine if it iswithin a range.
  • The || logical operator works best when testing a number to determine if it isoutside a range.
  • variable with block scope is only visible when the program is executing in the blockcontaining the variable’s definition.
  • You use the > operator to determine whether one string object is greater thenanother string object
  • An expression using the conditional operator is called a(n) conditional expression
  • The expression that is tested by a switch statement must have a(n) integer value
  • The expression following a case statement must be a(n) integer constant
  • A program will “fall through” a case section if it is missing the break statement.
  • t = (12 > 1); 1
  • t = (2 < 0); 0
  • t = (5 = = (3 * 2)); 0
  • t = (5 = = 5); 1
  • To increment a value means to increase it by one, and to decrement a value meansto decrease it by one
  • When the increment or decrement operator is placed before the operand (or to theoperand’s left), the operator is being used in prefix mode
  • When the increment or decrement operator is placed after the operand (or to the operand’sright), the operator is being used in postfix mode
  • The statement or block that is repeated is known as the body of the loop
  • Each repetition of a loop is known as a(n) iteration
  • A loop that evaluates its test expression before each repetition is a(n) pretest loop
  • A loop that evaluates its test expression after each repetition is a(n) posttest loop.