CSCI 1111 Chapter Notes - Chapter 3: Bitwise Operation, Switch Statement, Operand
Document Summary
Branching directs a program to execute either one statement group or another if (expression) { // statements to execute when the expression is true (first branch) else { // statements to execute when the expression is false (second branch) Braces { }, represent a grouping, such as a grouping of statements. An if-else expression commonly involves a relational operator or equality operator: a < b; a > b; a <= b; a >= b; a == b; a != b; The operation evaluates to a boolean value meaning either true or false. The relational and equality operators work for integer, character, and floating-point built-in types: the operators should not be used with strings. Only 1 branch will execute if (expr1) { else if (expr2) { else if (exprn) { else { Programmers commonly use the sequential nature of the multi-branch if-else arrangement to detect ranges of numbers.