summary04 - • Ways of ending a loop 1. List headed by...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
while (Boolean_Expression) { statement } Do { Statement } while (Boolean_Expression); for (Initialization_Action; Boolean_Expression; Update_Action) { Body_Statement } Basic Loop Syntax Summary Ch 7.3 – 7.4 7.3 More about C++ Loop Statements Increment/Decrement Operators: (ex. int number = 2 ) total = 2*(number++); total= 4 number= 3 total = 2*(++number); total= 6 number= 3 o same way with number--, --number use break to end a loop 7.4 Designing Loops
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • Ways of ending a loop 1. List headed by size 2. Ask before iterating 3. List ended with a sentinel value 4. Running out of input • Be careful and check if it’s off by one to fix common errors • When debugging, can trace the status of a variable by a cout statement at each loop • “If your program is very bad, do not try to debug it. Instead, throw it out and start over”...
View Full Document

This note was uploaded on 08/26/2009 for the course CS 140 taught by Professor Staff during the Fall '08 term at Southern Illinois University Edwardsville.

Ask a homework question - tutors are online