Selection Structures Flashcards
choosing between two or more alternative actions.
selection
an expression that evaluates to either true or false.
Boolean expression
When boolean expressions are formed they must set up a relationship between items in the expression. This relationship is set up using a set of operators called the _________________.
relational operators.
(=)
assignment operator
(==)
relational operator
combines two logical expressions and requires that both expressions be TRUE for the entire expression to be TRUE.
AND ( && )
combines two logical expressions and states that if either or both of the expressions are TRUE, the entire expression is TRUE
OR ( || )
precedes a single expression and gives its opposite as the result.
NOT (!)
GENERAL FORM:
if(Boolean Expression) { //Executable Statements ⋮ }
If statement
GENERAL FORM:
if(Boolean Expression) { //Statement1 ⋮ } else{ //Statement2 ⋮ }
If-else statement
GENERAL FORM:
switch (IntegralExpression) { //SwitchLabel…statement; ⋮ } GENERAL FORM FOR SWITCHLABEL IS case ConstantExpression: default:
Switch-case statement