CSCI 1301 Lecture Notes - Lecture 5: Boolean Expression, Primitive Data Type
Document Summary
Flow of control: the order in which statements are executed. Up to now, the order has been sequential. The program forms a tree (with multiple branches). A loop statement repeats a sequence of steps. The steps are repeated until a stopping condition occurs, at which point, the program breaks out of the loop . The type boolean and boolean expressions boolean is a primitive type with two values: true and false. A boolean expression evaluates to either true or false. false. 2 >= 1 //greater than or equal to. 1 != 2 //not equal to numdogs > numcats balance <= 0. A boolean variable can be given the value of a boolean expression by using an assignment operator. boolean ispositive = (number > 0); It"s good style to use names that suggest having a truth value. ispositive or systemsareok. The primary type is an if-else statement. if (booleanexpression) else. A compound statement (or block)is enclosed in { }.