5. The IF Statement Flashcards
control structures: a computer can proceed
- in a sequence
- selectively (branch) - making a choice
- repetitively (iteratively) - looping
If-Else statement
allows you to do diff things depending on a condition
condition
an expression whose value is true or false
symbols for conditions
> < == != >= <= !> etc
note on ==
cannot use = for conditions, as = is used for assigning
combining else and if
if ..
else if…
else ..
logical (boolean) expressions)
data type bool has logical values true and false
bool, true, false
reserved words
identifier true
has the value 1
identifier false
has the value 0
regional operators
allow comparisons
req 2 operands
return 1 if expresion true, 0 otherwise
comparing diff data types
unpredictable results produced
regional operators
== != < <= > >=
logical (boolean) operators
enable you to combine logical expressions
logical operators list
! (not)
&& (and)
|| (or)