Zusammenfassung der Ressource
Chapter 4
- Basic Program Constructs
- Sequence
- The execution of statements one
after another. This usually forms
the bulk of the code in any program
- Selection
- Selection is where the flow through a
program is interrupted and control is passed
to another point in the program. The
decision is based on a Boolean expression.
- Iteration
- Controlled by the state of a
Boolean expression, a
section of code is repeated.
- Recursion
- When a procedure or function calls itself
- This can be another way to produce iteration
- Global & Local Variables
- Global Variables
- Declared or initisialised
outside any sub programs;
functions or procedures
- Accessible to code written
anywhere in the program
- Can be accidentally
changed
- Local Variables
- Declared inside
a subprogram
- Only accessible within the
sub program it is declared in
- Branch
- BRA (Branch always)
- This is a jump instruction
that is always executed
- BRP (Branch if positive)
- This is a jump instruction that occurs when
the value in the accumulator is positive
- Subprograms
- Functions
- An algorithm that takes an input and
produces an output for each input
- Defining a function requirments
- A Function Name
- Any parameters needed by the function; that is,
the data that must be fed into the function
- The output - usually one output but
there can be zero or many outputs
- The processing code itself
- Returns a value
- Must be written as part of an equation
- Procedures
- Dosen't return a value
- Does not need to be written as part of an equation
- Exact definitions of functions and
procedures are slightly diffirent
depending on which language you use
- Parameter Passing
- By reference (By Ref)
- The function is given the actual memory address of
where the data for the variable is stored
- Any changes to the variable in
the function are permenant
- By value (By Val)
- A copy of the original data is passed the
function and any changes made are lost as
soon as the function is no longer in use
- The IDE (Integrated development environment)
- A text editor used for
writing source code
- Facilities for
automating the build
- A debugger
- Features to help with code writing, such
as pretty printing and code completion