4.0 Structured Programming, Recursion, Recording Macro, Flowcharts Flashcards
1
Q
two approaches to terminate loops
Do/Loop Structure
A
- decision loops
A. Do/If Exit
* terminated if condition is TRUE
B. Do While
* used when repetition is required while a condition is TRUE
* eg. when calculating summation of terms in infinite series, we want to continue adding
terms while absolute value of term T is larger than assumed tolerance Tol
Do While (Abs(T) >= Tol) Statements
Loop
while this condition met, statements executed after no longer TRUE, program continues on - count-controlled loops
▪ pre-set to repeat a fixed number of times
A. Do/If Exit
B. For/Next
-more efficient
1
Q
Do/Loop Structure
A
want to execute statement or group of statements many times
-infinite loop = a loop that never ends
- two approaches to terminate loops
2
Q
Recursion
A
recursion process = a process that calls itself
- eg. factorial calculation is a mathematical recursion
- can develop both non-recursive and recursive functions to compute factorials in VBA
* in Excel
▪ can use FACT(number)
* inVBA
▪ can use WorksheetFunction.FACT(number)
3
Q
Recording Macros
A
use to learn how to write VBA code to plot graphs and diagrams