2.0 Subs, Functions, Decisions, Flowcharts Flashcards

1
Q

modular programming

A

info needs to be broken down into parts and organized
-computer programs are organized in modules
▪ independent and self-contained
▪ designed for specific well-defined function
▪ focused and short
- a module can have one or more procedures
▪ each procedure small and self-contained
▪ eg. subs and functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

sub procedures

A

take more than one input parameter
- returns more than one result
- cannot be used in an expression
- general syntax:
Sub name([arglist])
[statements]
[Exit Sub]
[statements]
End Sub

  • the argument list of the first (main) Sub to be executed is BLANK
  • the arglist Subs that are called by other Subs usually has one or more arguments
  • a Sub can call another Sub to perform a part of the task
    ▪ after Call statement executed, the statements in name2 are executed, then execution resumes in
    name1 right before the Call name2 statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

functions

A

can take more than one input parameter
- returns only ONE RESULT
- can be used in formula to return the result in a cell or in an expression in a Sub
- general syntax:
Function name([arglist]) [statements]
[name = expression] [Exit Function] [statements]
[name = expression]
End Function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

structured programming

A

program statements are executed sequentially
▪ line by line
▪ starting at top and moving down to end
▪ creates limitations and inconveniences
- conventions to impose order on non-sequential algorithms that have been developed
- to allow program to take nonconsequential paths, ALL computer languages include statements
▪ decisions = branching of flow based on decision * 3 basic types
- If/Then/Else structures
- If/Then/Else If Cascade structures
- Select Case structures
▪ loops = looping of flow to allow statements to be repeated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how to tackle a problem while writing a code?

A

▪ think about the problem you’re trying to solve
▪ outline several possible methods of solutions
▪ select method that seems most clear and concise
▪ construct a detailed step-by-step procedure = an algorithm

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

flowcharts

A

for complicated algorithms, where decisions and/or looping occur, it’s more convenient to represent the algorithm with a flowchart
-graphical representation of an algorithm
-helps visualize the flow of the solution process
-must draw a flowchart before starting to write a code
-a series of blocks and arrows
- each block represents particular operation
- arrows represent sequence of those operations
(see photo)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If/Then/Else decision structure

A

syntax:
If condition Then [TrueStatements]
Else
[FalseStatements]
End If
- condition is a logical expression that evaluates
“TRUE” or “FALSE”
- true statements are one or more statements that are
executed if condition is TRUE
- false statements are one or more statements that are
executed if condition is FALSE
(See Photo)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

If/Then block structure

A

-True statements are one or more statements that are executed if condition is True
-False statements goes straight to junction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

loops

A

when you want to execute a statement or group of statements many times, use Do/Loop structure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

“Do/If Exit” and “For/Next”

A

count-controlled loops
-using “Do/If Exit” to loop pre-specified number of times
-For/Next loop provides a much more efficient means of implementing count-controlled iteration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Nesting

A

loops that are enclosed completely with other loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Orders of Priority in Evaluating Operators

A

Arithmetic: Parenthesis, Exponents, negation, multiplication/division, addition/subtraction
Relational: =, <>, <,>,<=,>=
Logical: Not, And, Or

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Relational Operators

A

= Equals or is equal to
<> Is not equal to
< Is less than
> Is greater than
<= Is less than or equal to
>= Is greater than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

algorithm

A

a set of instructions which, when followed, will produce a solution to the problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

select case structure

A
  • takes the “If/Then/Else If” to its logical conclusion
  • Select Case TextExpression [Case expression list1
    [statements]] [Case expression list2
    [statements]] [Case Else
    [elsestatements]]
    End Select
    -e.g. grade
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Do/If Exit

A

decision terminates if a condition is true
- general syntax:
Do
[statements]
If Condition Then Exit Do
[statements] Loop
- condition is a logical condition that tests “TRUE” or “FALSE”
- a single line “If” statement is used to exit the loop if condition is “TRUE”
- “FALSE” statements are one or more statements executed if the condition is “FALSE”