For unlimited access to Textbook Notes, a Class+ subscription is required.

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
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class
Class+
$8 USD/m
Billed $96 USD annually
Homework Help
Class Notes
Textbook Notes
30 Verified Answers
Study Guides
1 Booster Class