CSCI 150

Home | | Course Schedule | | Assignments | | Lecture Notes

Rules for using indentation:

It is important to use comments and indentation to make your programs easy to read and understand. This is particularly true when the programs start to get large and somewhat more complicated.


Each block of program code should be indented to show that the lines of code belong together. The best rule of thumb is to indent after each begin, and un-indent at each end statement. Note that for nested blocks you need to indent again (e.g. an if statement within a loop or a loop within a loop). Also indent after the var statement. Several examples follow:

Program indentation

Indenting conditionals and loops