Mind map
2. Structure of procedural programs

Map content
2. Structure of procedural programs
define terms
- statement- a single instruction- arithmetic or logical
- subroutine- a block of code separate from the main program but can be called by the main program
- procedure- a subroutine that executes the lines in there are then gives back control to the main, does not necessarily return a value
- function- a type of subroutine that returns a value after a caluclation
- parameter- data that is passed to a subroutine (and used by it) from the main program
- sequence-when instructions are followed one after the other
- selection- when the computer makes a decision as to which instruction to do, can be IF statement or a SWITCH CASE
- iteration- instructions repeated over and over again- loop, can be FOR, WHILE, DO-WHILE
- control structure- a block of code that tells wich order to do the instructions (loop or selection)
3 basic constructs
- sequence
- commands go one after the other
- follow each other in exectution
- iteration
- loops
- statements executed repeatedly
- 3 types
- FOR
- Count-controlled loop
- WHILE
- Condition-controlled loop
- only happens when condition is fullfilled
- WHILE UNTIL
- Condition-controlled loop
- runs once then checks condition
- FOR
- selection
- decision
- program can choose which statement to execute depending on user entry
- Two types
- IF- uses a condition or expression that gives a value
- SWITCH CASE- uses variable to decide the answer
- sequence
nested and iteration statements
- When one statement is put inside the other
- indent one statement inside the other
- can nest both loop and if statements
subroutines
- a small piece of code that is separate from the main program but is called from the main program, can be two types:
- Procedure- does the instructions then gives control back to the main program
- Function- same as procedure but returns an answer
- advantages
- Can call the subroutine makes time- does not make the program any longer
- program easier to understand and maintain- less clutter
- Easy to test- only need to test the subroutine
- Can reuse the subroutine over and over again
- if there is an error only need to change in one place
- parameters- data passed from the main program and then used by the subroutine
- scope- how long a variable can be used for
- variables: Local- can only be used in the subroutine, Global- can be used anywhere in the whole program
- a small piece of code that is separate from the main program but is called from the main program, can be two types:
recursive vs. iterations
- a subroutine that calls itself
- needs a stopping condition to stop it or will carry on forever...
- To solve:
- difference between iteration and recursion
- iteration:
- loop repeats instructions
- includes a tracking variable so ends
- uses less memory as there is only 1 function so 1 set of variable
- More complex
- count variable needs to be initialised before the loop starts
- recursion:
- uses a loop too
- uses less code
- runs slowly
- may run out of memory so the computer could crash
- hard to trace
- Need a stopping condition or never stops
- iteration:
Images and files in the map
Information
- Description
- A levels Computing Mind Map on 2. Structure of procedural programs, created by deepi1k73 on 23/03/2014.
- Created by
- deepi1k73
- Views
- 14
- Tags
- Rating





