Control Statement Usage Guide

 < Day Day Up > 



Table 6-1 will come in handy when deciding when to use a particular C++ control statement:

Table 6-1: Control Statement Usage Guide

Control Statement

Use

if

...for simple decision

if-else

...for decision with alternative action

switch

...in place of nested if-else statements where the condition is an integral or enumeration type

while

...when condition must be tested first

do

...when body must be executed at least once

for

...to loop for a known amount of times

break

...in case statement to prevent case statement fall- through;

...to terminate while, do-while, and for loops.

continue

...to skip to the end of a while, do-while, or for loop.

goto

...to perform unconditional jump to a labeled statement



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net