©1994-2003 Kevin Boone
Home     Section index     K-Zone home C++ tutorial (under construction)

Site search

Glossary
Confused by computer jargon? Look it up!

Shameless plug


Now available!

Articles
- Ten-minute guide to setting up a WAP site

- Talk like your boss: new developments in managerese

More...

Development
File handling in the Linux kernel

Java development for the Sony-Ericsson P800

SunONE Application Server 7 FAQ

More...

Linux
Using Linux with the Treo 600

- Linux on the Tecra M1

- Some notes on openzaurus

More...

Download
Java stuff

Linux stuff

More...

(Please read the download policy)

Home automation
The X10 system

Linux TW723 driver

More...

The K-Zone
K-Zone computing

K-Zone law

K-Zone education and science

K-Zone motorcycles

K-Zone DIY

K-Zone railways

K-Zone martial arts

About the author

K-Zone home page

 
standard functions
contents
while
C++ tutorial: loops and branches


Loops and branches are key features of all programs
So far we have examined simple C/C++ programs where the statements are executed, one at a time and from top to bottom. In practice, it will usually be necessary for the 'flow' of execution in a program to be more complex than this. 'Branches' are points in the program where execution can go one way or another; 'loops' are parts of a program that are executed repeatedly.

C/C++ has a reasonably large selection of loop and brach instructions; in fact, there are more than we theoretically need. Often the choice of which type to use is a matter of personal preference or convention. On a first reading, you might prefer just to look at the sections for 'if', 'while' and 'for'. These three constructs will give enough flexibility for simple applications.