slug
type
status
category
summary
date
tags
password
icon
CIE 9618 Computer Science Programming
11.1 Programming Basics
Implement and Write Pseudocode from a Given Design
Candidates should be able to:
- Interpret and convert a given design, such as a program flowchart or structured English, into pseudocode.
- Understand the logical flow and structure of algorithms and translate this understanding into readable and executable pseudocode.
Write Pseudocode Statements for Key Operations
- Declaration and Initialisation of Constants
- Syntax Example: Constants are values that do not change during program execution.
- Declaration of Variables
- Syntax Example:
Variables are declared with a specific data type like
INTEGER
,STRING
, etc.
- Assignment of Values to Variables
- Syntax Example:
Assignment uses
←
to assign a value to a variable.
- Expressions Involving Arithmetic or Logical Operators
- Syntax Example:
Candidates should handle operators such as
+
,,
,
/
,AND
,OR
, andNOT
.
- Input and Output
- Input from the Keyboard:
- Output to the Console:
Use Built-in Functions and Library Routines
- Candidates should know how to use standard functions such as:
LENGTH(string)
to determine the length of a string.SUBSTRING(string, start, length)
to extract part of a string.
- Functions outside the guide will be provided during the exam.
11.2 Constructs
Using Pseudocode Constructs
- IF Statements
- Include the
ELSE
clause and nestedIF
statements: - Nested Example:
- CASE Structure
- Syntax:
- Count-Controlled Loop
- Example:
- Pre-condition Loop
- Example: Executes only if the condition is true before entering the loop.
- Post-condition Loop
- Example: Executes at least once, regardless of the condition.
Justification for Loop Structures
- Use a count-controlled loop when the number of iterations is known in advance.
- Use a pre-condition loop when a condition must be met before starting.
- Use a post-condition loop when an action must execute at least once.
11.3 Structured Programming
Procedures
- Definition and Use
- A procedure is a block of reusable code that performs a task and does not return a value. Syntax Example:
- Appropriate Usage
- Use a procedure when you need to encapsulate repetitive tasks without requiring a return value.
- Parameters
- Procedures can have parameters for passing data:
- Pass by Value: A copy of the value is passed, and changes do not affect the original.
- Pass by Reference: The actual variable is passed, allowing direct modification.
Functions
- Definition and Use
- A function returns a value as part of an expression. Syntax Example:
- Appropriate Usage
- Use a function when a calculation or process must return a result for use elsewhere in the program.
- Terminology
- Procedure/Function Header: The first line specifying the name, parameters, and (for functions) return type.
- Interface: Describes how the procedure or function interacts with the rest of the program.
- Parameters and Arguments:
- Parameter: The placeholder in the definition.
- Argument: The actual value passed during a call.
- Return Value: The result provided by a function.
Efficient Pseudocode Writing
- Focus on readability, logical structure, and avoidance of redundancy.
- Ensure variables and constructs are clearly defined.
This comprehensive understanding will prepare candidates to confidently approach algorithm construction, pseudocode development, and structured programming for CIE 9618 exams.
CIE 9618 编程
11.1 编程基础
根据给定设计实现和编写伪代码
- 学生需要能够将程序流程图或结构化英语转换为伪代码。
- 理解算法的逻辑流程和结构,并将其转化为可读和可执行的伪代码。
编写伪代码语句
- 声明和初始化常量
- 示例: 常量在程序运行期间不会改变。
- 声明变量
- 示例:
变量需要声明具体的数据类型,如
INTEGER
(整数)、STRING
(字符串)等。
- 赋值语句
- 示例:
使用
←
将值赋给变量。
- 算术和逻辑表达式
- 示例:
操作符包括
+
、、
、
/
、AND
、OR
和NOT
。
- 键盘输入与控制台输出
- 输入示例:
- 输出示例:
使用内置函数和库函数
- 学生需了解如何使用常见函数,如:
LENGTH(字符串)
获取字符串长度。SUBSTRING(字符串, 起始位置, 长度)
提取子字符串。
- 未列在伪代码指南中的函数将在考试中提供。
11.2 结构
使用伪代码结构
- IF 条件语句
- 包括
ELSE
分支和嵌套的IF
语句: - 嵌套示例:
- CASE 结构
- 示例:
- 计数控制循环
- 示例:
- 前置条件循环(Pre-condition Loop)
- 示例:在进入循环前必须满足条件。
- 后置条件循环(Post-condition Loop)
- 示例:至少执行一次,然后检查条件。
循环结构的优劣比较
- 计数控制循环适合已知迭代次数的场景。
- 前置条件循环适合在进入循环之前需要验证条件的场景。
- 后置条件循环适合至少需要执行一次任务的场景。
11.3 结构化编程
过程(Procedure)
- 定义和使用
- 过程是一段可复用的代码块,不返回值。 示例:
- 适用场景
- 当需要封装重复任务且不需要返回值时,可以使用过程。
- 参数
- 过程可以接收参数以传递数据:
- 按值传递(Pass by Value):传递值的副本,不会影响原始变量。
- 按引用传递(Pass by Reference):传递变量本身,可直接修改变量。
函数(Function)
- 定义和使用
- 函数返回一个值,可在表达式中使用。 示例:
- 适用场景
- 当需要返回计算结果或处理结果时,可以使用函数。
- 术语解释
- 过程/函数头(Header):定义过程或函数的第一行,包括名称、参数和返回类型。
- 接口(Interface):描述过程或函数与程序其他部分的交互方式。
- 参数和实参:
- 参数(Parameter):定义时的占位符。
- 实参(Argument):调用时传递的实际值。
- 返回值(Return Value):函数执行后的结果。
高效编写伪代码
- 注重可读性、逻辑结构以及减少冗余。
- 确保变量和结构清晰明了。
通过以上知识点的掌握,考生可以自信地应对 CIE 9618 考试中关于算法设计、伪代码开发和结构化编程的考核。
- 作者:现代数学启蒙
- 链接:https://www.math1234567.com/programming
- 声明:本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。
相关文章