ECS 30 Chapter Notes - Chapter 3: Decision-Making, Logical Connective, Unary Operation
Document Summary
Decision making in a program is focused on choosing to execute one set of program statements over another set. Comparing things in c involve relational operators, or operators that compare the values. The comparison results in a boolean type, either a 0 or 1, or false and true. A common mistake involving the equality comparison is type one = when in reality it needs to have two ==. To set up a statement to make decisions, you use the simple if statement, which uses the keyword if. e. g. if (comparison) The if statement does not require a ; on the relational comparison, but after the action it is supposed to do. This action is most often written on a new line for the sake of clarity. If statements allow you to be selective about what type input you will get, for example, if you receive a number outside a desired range you can change it with an if statement check.