Chapter 4 Flashcards Preview

Programming Fundamentals > Chapter 4 > Flashcards

Flashcards in Chapter 4 Deck (24)
Loading flashcards...

used to compare numeric data; binary; L to R associativity

relational operators


exp formed by relational operators

relational exp


value can only be T or F; if operands don't meet meaning of operand, exp if false; another name for relational exps

Boolean expression


prgm where statements are executed in sequence, w/out branching off in another direction

sequence structure


prgrm where some statements are only executed under certain circumstances; a specific action is only taken when a specific condition exists

decision structure


action performed only when a certain condition exists

conditionally executed


one way to code a decision structure; if exp inside () is true, the very next statement or block is executed; otherwise, it's skipped; condly executed statement should appear on line after ___ and should be indented one level from ___

if statement


expansion of another statement; an exp is evaluated, if T, statement/block is executed, if F, a separate group of statements is executed; leads program to execute 1 of 2 exclusive paths

if/else statement


makes certain types of nested logic simpler to write; if exp_1 is T, it's executed and rest are ignored, otherwise, if exp_2 is T, it's executed and rest of structure is ignored, etc.

if/else if statement


the last ___ clause in an if/else if statement that doesn't have an if statement following it; optional; can be used to catch errors

trailing else


typically a bool variable that signals when some condition exists in the prgm; when set to F, it indicates cond doesn't exist; when set to T, it means cond exists



used to combine 2 or more relational exps into one

logical operators


takes 2 exps as operands and creates exp that's true when both sub-exps are true; can be used w/ if statements to condly print cout statement; exps must be on both sides of operator; can be used to simplify prgrms that would otherwise be nested if statements; can be used to det if # is inside range

logical AND operator (&&)


if exp on left side of logical operator that reqs two operands is F, the exp on right side won't be checked

short circuit evaluation


takes 2 exps as operands and creates an exp that's T when either of them are T; complete exps must be used on both sides; can use to det if # is outside range

logical OR operator (||)


takes an operand and reverses its truth or falsehood if exp is T, returns F, and if exp is F, returns T; is equivalent to asking is something is not something (if..not)

logical NOT operator (!)


allows user to det course of action by selecting it from a list of actions; can use if/else statements or if/else if statements to set up a menu or switch statements

menu-driven program


process of inspecting data given to prgm by user and deting if its ___ (e.g.: checking if in correct range or mathematicall possible)

input validation


tests value of an integer exp and uses that value to det which set of statements to branch to

switch statement [switch(IntegerExp) ... case ConstantExp: ... case ConstantExp ... default: ]


what can be used in integer exp of switch statement

1) variable of any integer data type, including char
2) exp whose value is of any integer data types


must be of an integer data type, may be literal or integer named constant; can't be a variable or relational exp

constant exp


marks beg of section of statements; prgm branches to these statements if value of switch exp matches that of __ exp



optional section that comes after case statements; prgrm branches to this section if none of case exps match switch value; fcns like trailing else



come in line following each case statement; show prgm where to stop executing block of statements for case; not needed in default section, but you can put one there; can be strategically omitted to allow fall thru, which enables to branch to same set of statements for multiple exps or to actually print all below statements