1 Program Constructs
Quiz yourself by thinking what should be in
each of the black spaces below before clicking
on it to display the answer.
Help!
|
|
||||
---|---|---|---|---|---|
Statement | A single instruction within the algorithm (which can be executed), e.g. Input X.
🗑
|
||||
Keyword | Word which is already used for a purpose within the language. Reserved word/cannot be used as an identifier.
🗑
|
||||
Identifier | Symbolic name given to a variable, constant or subroutine.
🗑
|
||||
Sequence | All instructions are executed once in the order in which they appear.
🗑
|
||||
Selection | A condition is used to determine whether or not sections of code will be executed. E.g. IF....THEN....(ELSEIF...)ENDIF / SELECT CASE
🗑
|
||||
SELECT (CASE) | Value of variable/expression used to decide which of a number of statement blocks is executed. There can be a default option.
🗑
|
||||
Advantages of SELECT over IF | All the alternatives depend on the value of one variable. So this makes the code clearer and easier to read/write. Allows multiple branches and avoids nested Ifs. Avoids numerous repeats of similar conditions.
🗑
|
||||
Iteration | Code is executed repeatedly for a given number of times or until a condition is met.
🗑
|
||||
Count controlled loop (FOR) | FOR loop is set up with a fixed number of iterations. Uses loop variable. E.g. FOR Count = 1 TO 10.....NEXT Count.
🗑
|
||||
Condition controlled loops (WHILE / REPEAT UNTIL) | WHILE loop runs repeatedly depending on a condition (it repeats while the condition is true. E.g. WHILE Count < 11….. END WHILE. REPEAT UNTIL loop repeats until some condition becomes true. E.g. REPEAT … UNTIL Count > 10.
🗑
|
||||
Parameter | A description of an item of data supplied to a subroutine. It is given an actual value/address when the subroutine is called. It is used as a variable within subroutine.
🗑
|
||||
Procedure | A named section of code which performs a task. Can be called from parent program and returns control to parent program when complete. Used as a statement in the main program. Can be sent parameters.
🗑
|
||||
Function | A named section of code. It is called as part of an expression e.g. Num = LENGTH(Name) which returns a single value when called. The value replaces the function call.
🗑
|
||||
RETURN | Return tells the program to exit the function and supplies the value which will be used by the main program.
🗑
|
||||
OUTPUT | Output tells the program to display a value on the user interface.
🗑
|
||||
Recursion | When a subroutine calls itself with different parameter(s) until a stopping condition is met, (when it ‘unwinds’).
🗑
|
||||
Advantages of iteration | Uses only one set of variables so more efficient use of memory and can be faster. Less likely to run out of stack space.
🗑
|
||||
Disadvantages of iteration | Algorithm may be more difficult to follow/trace because variables are being reused. Need to be careful to get conditions of loops correct. Humans often express the problem in a recursive way (rather than an iterative way).
🗑
|
||||
Advantages of recursion | Can be easier to program or more intuitive with an inherently recursive algorithm.
🗑
|
||||
Disadvantages of recursion | Uses many sets of variables (one set per call) therefore less efficient use of memory and often slower and can run out of stack space causing run
🗑
|
||||
Nesting | When a construct is written completely contained within another. They are not allowed to overlap.
🗑
|
Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Created by:
Chelsea2760
Popular Computers sets