Chapter 4 Flashcards
(25 cards)
What are the 2 most common control structures?
Selection and Repetition.
What is selection?
When the program executes a particular statement depending on some conditions.
What is repetion?
When the program repeats particular statements a certain number of times based on some conditions.
What is a logical expression?
An expression that evaluates to true or false.
What operator is this: ==
equal to
what operator is this: !=
not equal to
what operator is this:
less than
what operator is this: >
greater than
what operator is this: <=
less than or equal to
what operator is this: >=
greater than or equal to
How are one way selectors incorporated ?
Using an if statement
if (expression) {
statement;
}
What is two-way selection?
Choosing between two alternatives.
How are two-way selectors incorporated ?
if...else statements. if (expression) { statement; } else { statement; }
What is a compund statement.
A statement that consist of a sequence of statement enclosed in curly braces
{
statement 1, statement 2, statement n;
}
What is it called when control staement are located within each other?
Nesting
What is the pairing else with an if rule?
An else statement is assocaited with most recent if statement.
What is the conditional operator (or ternary operator)?
”?” the 3 arguments that explain what the condition is, what the results will be if the condition is true and result when the condition is false.
expression 1 ? expression 2 : expression 3
What is short curciut evaluation (of a logical operator)?
A process in which a computer evaulates a logical expression from left to right and stops as soon as a final value is of the expression is known.
‘R’ > ‘T’ Is the statement true of false why?
False, because ‘R’ comes before ‘T’ in alphabet and in is a lesser number in ASCII Characters
What opperator is this: &&
And
What opperator is this: ||
Or
What opperator is this: !
Not
What hold opperators hold the highest precedence?
!, +, - (unary operators)
What is the rest of the precedence order?
*, /, % second
+, - third
=, > fourth
==, != fifth
&& sixth
|| seventh
= (assignment operator) last