Computer Science 1026A/B Chapter Notes - Chapter 3: Relational Operator, Flowchart, Lexicographical Order
terubarenuka and 39895 others unlocked
26
COMPSCI 1026A/B Full Course Notes
Verified Note
26 documents
Document Summary
The if statement: the if statement allows a program to carry out different actions depending on the nature of the data to be processed. or. The if statement is used to implement a decision. When a condition is fulfilled, one set of statements is executed. Compound statements are consist of a header and a statement block. Compound statements require a colon (:) at the end of the header. The statement block is a group of one or more statements, all of which are indented to the same indentation level. A statement block begins on the line following the header and ends at the first statement indented less than the first statement in the block. You can use any number of spaces to indent statements within a block, but all statements within the block must have the same indentation level. Whatever instruction given inside the block is only executed if the header conditions turn out to be true.