Topic 5 - Selection Statements Flashcards
Besides return statements and expression statements, what are the other types of statements?
1) selection statements
2) iteration statements
3) jump statements
What is the precedence of relational operators relative to arithmetic operators?
Lower.
What is the relational operators and equality operators association?
Left-associative.
What is the precedence of equality operators relative to relational operators?
Lower.
The logical operators treat any nonzero operand as ___
and any zero operand as ____?
True
False.
What is conditional expression syntax?
expre1 ? expr2 : exp3 which means:
if expr, then e ,xpr2, else expr3
Does C89 have a proper boolean type?
No, had to declare an int variable and assign it either 0 or 1
What is the boolean type in C99?
_Bool type
_Bool flag;
It is an integer type that can only take values 0 and 1
What happens when you attempt to store a non-zero value into a _Bool variable?
Causes the variable to be assigned 1
What does C99 header do?
Defines a macro, bool, that stands for _Bool:
bool flag; same as:
_Bool flag;
The switch statement must be followed by a:
an integer, no floating point numbers or strings.
What happens when the default case is missing and the controlling expression’s value doesn’t match any case label?
the control passes to the next statement after the switch.
What happens when “Break” isn’t included in a case label body?
Control flows to next case label.