Putting it together · 综合运用
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
English
One program uses several constructs
- A 9618 answer mixes
DECLARE,←,IF…THEN,FORandOUTPUT. - Indent the body of a loop. Put
THENon theIFline. - A short comment with
//says what a block is for.
中文
一个程序用上几种结构
- 一份 9618 答案会把
DECLARE、←、IF…THEN、FOR和OUTPUT写在一起。 - 循环体要缩进。
THEN放在IF那一行。 - 用
//写一句短注释,说明这一段是做什么的。
// Total the five marks, then say whether the total reaches 20.
DECLARE Mark : ARRAY[1:5] OF INTEGER
Mark[1] ← 4
Mark[2] ← 8
Mark[3] ← 6
Mark[4] ← 2
Mark[5] ← 5
DECLARE Total : INTEGER
Total ← 0
FOR I ← 1 TO 5
Total ← Total + Mark[I]
NEXT I
OUTPUT "Total = ", Total
IF Total >= 20 THEN
OUTPUT "target met"
ELSE
OUTPUT "below target"
ENDIF
English
What this course left for A2
- Random files, classes, enumerated types and pointers are in the full 9618 guide.
- They are assessed at A2, not in this AS course.
- The IGCSE course on this site uses the 0478 rules for 2026–2028. Do not copy those into a 9618 answer.
中文
这门课留给 A2 的内容
- 随机文件、类、枚举类型和指针都在完整的 9618 指南里。
- 它们在 A2 考查,不在这门 AS 课里。
- 本站的 IGCSE 课程使用 0478 在 2026–2028 的规则。不要把那些规则抄进 9618 的答案。
English
Now you try
- Total an array, then choose a message with
IF.
中文
现在你来试
- 把数组求和,再用
IF选择一条消息。
The array is filled for you. Output Total = 25 on one line, then target met because 25 is at least 20. · 数组已为你填好。在一行输出 Total = 25,然后因为 25 不少于 20,再输出 target met。
Click Run to see the output here. · 点击“运行”查看此处输出。