Textbook Notes (280,000)
CA (160,000)
Ryerson (10,000)
ITM (800)
ITM 200 (20)
Chapter 7

Chapter 7


Department
Information Technology Management
Course Code
ITM 200
Professor
Vikraman Baskaran
Chapter
7

This preview shows page 1. to view the full 4 pages of the document.
Chapter 7 – More control structures
7.1 Non-termination
Non-terminating loop (aka infinite loop) occurs when there is either
oNo condition in the loop body for changing the variables used in the loop test
oThe variables are changed, but not in such a way that the test can eventually take
the value false
An unintentionally non-terminating loop is an example of a run-time error
oThe program runs forever and has to be stopped by the user
Non-termination is not always an error, some control programs are not supposed to stop
oFor example, software to control a hospital life-support machine, or the cooling
system of a nuclear power station
7.2 Nesting of if-else and while statements
Example of a program on pg 143-145
Indentation
When writing programs with nested control structures, it becomes even more important to
use consistent indentation
This makes the program much easier to understand and facilitates debugging and
modification
7.3 The single-branch if statement
Sometimes you want your programs to choose, not between 2 alternative actions but
between 1 action and doing nothing
In this case you can use a single-branch if statement
Example on pg 145-146
Single-branch if statement
Syntax
oIf (<TEST>)
www.notesolution.com
You're Reading a Preview

Unlock to view full version