LAB6 F11

# LAB6 F11 - 2 1 = 2 Add(1 • Add(1 = 1 STOP HERE(Decision...

This preview shows pages 1–7. Sign up to view the full content.

Recap – Decision Structures (Ch. 7) Concept of Looping (Ch. 8, pp. 179 – 180) Recursive functions (Ch. 8, pp. 189 – 192) Types of Looping Statements (Ch. 8, pp. 201 – 207) Simple For – Next Loops (Ch. 8, pp. 180 – 188)

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

View Full Document
Used when a set of codes have to repeated multiple times. Eg.: Enter 5 inputs. Input # i Next i Yes No
Function that calls itself Be cautious when using recursive functions; as, like the variant data type they too can lead to problems ( infinite looping ) The key while programming recursive functions is to use Decision Structures to stop the infinite loop

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

View Full Document
Ex. Program (Function named: Add) to calculate 1 + 2 + 3 +….+ N If N = 3 then Add(3) = 3 + 2 + 1 Add(3) = 3 + Add(2) Add(2) =

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2 + 1 = 2 + Add(1) • Add(1) = 1 STOP HERE (Decision) • For – Next we will focus on this one • Do – Loop (Conventional) • While - Wend • Do – Loop While or Do While – Loop • Do – Loop Until or Do Until - Loop • For – Each All looping structures work on the same concept as described earlier. However, each type of loop has a different syntax. • Syntax (Simple For Loop) : For Counter = Min# To Max# Step # Procedure(s) Next Counter • Can have any number of lines inside the For loop 1. Set Counter = Min# 2. Execute Procedure (once) 3. Increment Counter (New_Counter = Old_Counter + Step#) 4. Check – If Counter is in Range YES – Repeat from Step 2 NO – Step/End Loop...
View Full Document

## This note was uploaded on 10/12/2011 for the course ENGR 1412 taught by Professor Staff during the Spring '08 term at Oklahoma State.

### Page1 / 7

LAB6 F11 - 2 1 = 2 Add(1 • Add(1 = 1 STOP HERE(Decision...

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

View Full Document
Ask a homework question - tutors are online