8 1 Notes

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

8.

1 Programming Concept
1. Declare and use variable and constants
2. Understand and use the basic data types, including integer, real, char, string, boolean
3. Understand and use input and output
4. (a) Understand and use the concept of sequence
(b) Understand and use the concept of selection, including IF/CASE statements
© Understand and use the concept of iteration, including count-controlled loop, pre-
condition loop, post-condition loop
(d) Understand and use the concepts of totaling and counting
(e) Understand and use the concept of string handling. Including length, substring, upper,
lower, the first character of a string can be zero or one
(f) Understand and use arithmetic, logical, and Boolean operators
5. Understand and use nested 嵌套 statements
6. (a) Understand what is meant by procedures, functions, and parameters

Procedure - A set of programming instructions


- grouped together under a single name
- that can be called multiple times
Functions - A set of programming instructions
- grouped together under a single name
- that can be called multiple times
- return a value back to the main program
Parameters A variable that stores the value of arguments passed to the procedure or
functions.
Arguments Actual value passed to the procedure or function
Header The first statement in the definition:
- the name of procedure or function
- any parameter passed to the procedure or function, and their data
type
- the data type of the return value of the function

(b) Define and use procedures and functions, with or without parameters
(c) Understand and use local and global variables
Global Variable Can be used any part of the program
Local Variable Can be used only in the part of the program
it is declared in.
- if a local variable is used outside of
its score, an ‘undefined error’ will
occur.
Scope (可用范围) Where it can be used

7. Understand and use library routines, including MOD, DIV, ROUND, RANDOM

8. Understand how to create a maintainable program, including appropriate use of


meaningful identifier, the commenting feature provided by the programming language,
procedures and functions, relevant and appropriating commenting of syntax
Meaningful identifier - used in
variables/constants/arrays/procedures
and functions
Use of procedures and functions Divide each task into modules
Commenting Readable code
Easier to maintain
Clear documentation
PROCEDURE f(num1, num2, num3)
IF num1 > num2 AND num1 > num3
OUTPUT num1
ELSE IF num2 …

FUNCTION f(str1:STRING, str2:STRING) RETURNS STRING


DECLARE str3: STRING
Str3 <- SUBSTRING(str1, 1, 3) & SUBSTRING(str2, 1, 3)
RETURN str3
ENDFUNCTION

You might also like