OLD PROGRAMMING CARDS Flashcards
What are the standard algorithms?
5
- Input Validation
- Count Occurence
- Linear Search
- Find Min
- Find Max
Standard Algorithms:
Input Validation Code
start fixed loop
get input from user
conditional loop - while input not match conditions
display error message
get input from user
end conditional
end fixed loop
Standard Algorithm:
Count Occurence Code
total = 0
get value from user
fixed loop
if array index = value
total = total + 1
end if
next
display message
Standard Algorithms:
Linear Search Code
found = false
counter = 0
get search value input
Do
if searchValue = array index then
found = true
msgbox(“The program found the value at position “ & counter)
else
counter = counter + 1
endif
loop until counter = end of array or found = true
if found = false
display message
end if
Standard Algorithms:
Find Min
min = first array index
fixed loop
if array index is less than min then
assign value to min
end if
next
display message
Standard Algorithms:
Find Max
max = first array index
fixed loop
if array index is more than max then
assign value to max
end if
next
display message
What can variables be declared as?
2
- Local
- Global
Local Variable Defintion
2
- A variable declared in a sub program
- Scope of variable is the sub program it is declared in
Global Variable Defintion
- A variable that is declared outwith a sub program
- Scope of variable is the entire program
Implementation:
Parallel Arrays Definition
Arrays used in conjuction of each other so programmers can display information together
Implementation:
Records Definition
Programmer defined data types
Implementation:
How can multiple data types be held in one array?
By creating a record structure and declaring an array of records
Implementation:
Record Structure Code
Structure NAME
public NAME as DATATYPE
public NAME as DATATYPE
public NAME as DATATYPE
End Structure
Implementation:
Array of Records Code
Dim ARRAYNAME(num) as **NAME*
Implementation:
Module Programming Examples
3
- Sub-Program
- Procedure
- Function
Implementation:
Sub-Program Definition
A block of code that can be called and accessed by the main program
Implementation:
Procedure Defintion
Sub-programs designed to perform a series of commands with values sometimes passed to/from another part of the program
Implementation:
Function Definition
Sub-programs designed to always return a single value to another part of the program
Implementation:
Formal & Actual Parameters
Implementation:
What is parameter passing?
When a local variable is passed from one sub program to another
Implementation:
What are the ways a parameter can be passed?
2
- By reference
- By value
Implementation:
By Reference Definition
The sub-program has direct access to the memory location holding the value. This means any changes to the value being held will be stored.
Implementation:
By Value Definition
The sub-program is given a temporary copy of the value being held in the variable. The value can be changed, but this will not be stored
Implementation:
How must arrays be parameter passed?
By Reference
Implementation:
What is a pre-defined function?
Code built into the software that does not need to be created by a programmer
Implementation:
What are the pre-defined functions?
4
- Character to ASCII
- ASCII to Character
- Decimal to Integer
- Find the Remainder
Implementation (pre-defined functions):
Character to ASCII Code
Asc(“A”)
Returns 65
Implementation (pre-defined functions):
ASCII to Character Code
Chr(65)
Returns A
Implementation (pre-defined functions):
Decimal to Integer Code
CInt(3.14)
Returns 3