CSCI 1105 Lecture 6: CSCI 1105 Lecture 5 - Decisions & Relational Operations
CSCI 1105 verified notes
6/25View all
Document Summary
Apply what you learn to checking user input. Compare integers, floating point numbers, and strings. A computer program needs to make decisions based on input, or circumstances: allows a program to carry out different actions depending on the nature of the data to be processed. For example, buildings often skip the 13th floor, and elevators should too: the 14th floor is the 13th floor, so, every floor above (cid:1005)(cid:1006) is really (cid:858)floor (cid:1005)(cid:859) If floor > 12, actual floor = floor 1: the two keywords of the if statement are if, else. One of the two branches is executed: true (if) branch, false (else) branch. A statement might not even need an else branch. The if statement is an example of a compound statement. Compound statements span multiple lines and consist of a header and a statement block. Compound statements require a colon at the end of the header.