Lecture 2-18-08

Lecture 2-18-08 - Matthew Bessette ENGR 141-107 Looping...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Matthew Bessette ENGR 141-107 February 18, 2008 Looping Structures: “for” Loops - Why do we need looping? o Repetition of a code segment o Recall the algorithm for calculating a factorial o Soil homework – “repeat unless organic” - Definite Loops – For Loops o A segment of code executes a certain number of times o Ex: counting, data processing, sampling - Indefinite Loops – While loops o Also referred to as conditional loops o A segment of code repeated executes until a certain condition is satisfied o Any for-loop can also be written as a while loops o Ex: validating input, calculations - Definite Loops: For loops o Execute a certain number of times o Sampling rate o Counting backwards o Palm p.211 for counter=start:step:finish %executable statements (may use counter) % it is bad practice to change loops index numbers % counter = 2 (causes code to never finish infinite loop) % counter=counter-3 End - Where to Use? o
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/21/2008 for the course ENGR 141 taught by Professor Bowman during the Spring '07 term at Clemson.

Page1 / 2

Lecture 2-18-08 - Matthew Bessette ENGR 141-107 Looping...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online