20.01.2015 Views

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition

Programming Logic and Design Sixth Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Underst<strong>and</strong>ing the Three Basic<br />

Structures (continued)<br />

• Loop structure<br />

while testCondition continues to be true<br />

do someProcess<br />

while quantityInInventory remains low<br />

continue to orderItems<br />

<strong>Programming</strong> <strong>Logic</strong> & <strong>Design</strong>, <strong>Sixth</strong> <strong>Edition</strong> 13<br />

Underst<strong>and</strong>ing the Three Basic<br />

Structures (continued)<br />

• All logic problems can be solved using only these<br />

three structures<br />

• Structures can be combined in an infinite number<br />

of ways<br />

• Stacking<br />

– Attaching structures end-to-end<br />

• End-structure statements<br />

– Indicate the end of a structure<br />

– The endif statement ends an if-then-else structure<br />

– The endwhile ends a loop structure<br />

<strong>Programming</strong> <strong>Logic</strong> & <strong>Design</strong>, <strong>Sixth</strong> <strong>Edition</strong> 14<br />

Underst<strong>and</strong>ing the Three Basic<br />

Structures (continued)<br />

Underst<strong>and</strong>ing the Three Basic<br />

Structures (continued)<br />

• Any individual task or step in a structure can be<br />

replaced by a structure<br />

• Nesting<br />

– Placing one structure within another<br />

– Indent the nested structure’s statements<br />

• Block<br />

– Group of statements that execute as a single unit<br />

Figure 3-6 Structured flowchart <strong>and</strong> pseudocode with three stacked structures<br />

<strong>Programming</strong> <strong>Logic</strong> & <strong>Design</strong>, <strong>Sixth</strong> <strong>Edition</strong> 15<br />

<strong>Programming</strong> <strong>Logic</strong> & <strong>Design</strong>, <strong>Sixth</strong> <strong>Edition</strong> 16<br />

Underst<strong>and</strong>ing the Three Basic<br />

Structures (continued)<br />

Underst<strong>and</strong>ing the Three Basic<br />

Structures (continued)<br />

Figure 3-7 Flowchart <strong>and</strong> pseudocode showing nested structures—a<br />

sequence nested within a selection<br />

<strong>Programming</strong> <strong>Logic</strong> & <strong>Design</strong>, <strong>Sixth</strong> <strong>Edition</strong> 17<br />

Figure 3-8 Flowchart <strong>and</strong> pseudocode showing nested structures—a loop<br />

nested within a sequence, nested within a selection<br />

<strong>Programming</strong> <strong>Logic</strong> & <strong>Design</strong>, <strong>Sixth</strong> <strong>Edition</strong> 18<br />

3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!