Untuk pendidik: slide pelajaran, catatan ulasan siap pakai untuk Programming Concepts (Computer Science, CIE) — gunakan dalam pelajaranmu, atau jalankan topik sebagai aktivitas kelas interaktif yang dimainkan pembelajar sebagai permainan langsung.
Boolean operators: `AND`, `OR`, `NOT` used to combine conditions.
Arithmetic operators compute values, comparison operators produce a Boolean, and Boolean operators combine them.
Procedures & Functions
Procedures do not return a value; defined with `PROCEDURE ... ENDPROCEDURE` and called with `CALL`.
Functions return a value; defined with `FUNCTION ... RETURNS <type> ... ENDFUNCTION` and called in expressions.
Parameters pass data into sub-programs; multiple parameters allowed.
Sub-programs improve readability, maintainability, and avoid code duplication.
A subroutine is a named, reusable block: the main program calls it, it does its task, and it returns.
Local & Global Variables
Local variables declared inside a sub-program; only accessible there; destroyed when the sub-program ends.
Global variables declared at the outermost level; accessible from anywhere in the program.
Use local variables to avoid unintended side-effects; global variables can be modified by any part of the program.
Library Routines
Library routines are pre-written, reusable code (e.g., `RANDOM`, `ROUND`) that save time and are already tested.
`RANDOM` generates random numbers; in pseudocode `RANDOM()` returns a random number between 0 and 1 inclusive; in Python `import random; random.randint(a,b)`.
`ROUND` rounds a number to a specified number of decimal places: `ROUND(value, places)`.
Maintaining Programs
Use layout, indentation, comments, meaningful variable names, white space, and sub-programs to make code easy to maintain.
Consistent use of these techniques improves readability and reduces errors when modifying code.
Slide
Sign up free to view the lesson slides
Step through every slide for this topic — plus flashcards and revision notes — with a free account.
Pratinjau gratis — 8 dari 40 soal. Daftar untuk melihat semuanya.
1.Which of the following is the correct way to declare a variable in pseudocode?
Easy
ADECLARE Age : INTEGER
BDECLARE Age = INTEGER
CAge : INTEGER
DINTEGER Age
2.Which data type would be most appropriate to store the value 'True'?
Easy
ABOOLEAN
BSTRING
CINTEGER
DCHAR
3.What is the output of the following pseudocode?
Total ← 0
FOR X ← 1 TO 3
Total ← Total + X
NEXT X
OUTPUT Total
Medium
A6
B3
C1
D0
4.Which of the following correctly represents a condition-controlled loop in pseudocode?
Medium
AWHILE Colour ≠ 'Red' DO
INPUT Colour
ENDWHILE
BFOR X ← 1 TO 10
OUTPUT X
NEXT X
CREPEAT
INPUT Colour
UNTIL Colour = 'Red'
DIF Colour = 'Red' THEN
OUTPUT 'Stop'
ENDIF
5.What is the value of Result after executing the following pseudocode?
Result ← 10 MOD 3
Hard
A1
B3
C0
D10
6.Which of the following is a valid constant declaration in pseudocode?
Medium
ACONSTANT π ← 3.142
BCONSTANT π = 3.142
CDECLARE π : CONSTANT ← 3.142
Dπ CONSTANT ← 3.142
7.What is the purpose of a procedure in programming?
Easy
ATo perform a task without returning a value
BTo return a value
CTo store data permanently
DTo handle user input
8.Which of the following is the correct pseudocode to output the length of a string stored in variable Word?
Medium
AOUTPUT LENGTH(Word)
BOUTPUT LEN(Word)
COUTPUT Word.LENGTH
DOUTPUT LENGTH Word
Soal lainnya
9.What is the output of the following pseudocode?
Word ← 'Revision'
OUTPUT SUBSTRING(Word, 1, 3)
Hard
ARev
Bvis
CRevi
DRevision
10.Which Boolean operator returns True only when both conditions are True?
Medium
AAND
BOR
CNOT
DXOR
11.What is the value of Result after executing the following pseudocode?
Result ← 17 DIV 4
Hard
A4
B1
C4.25
D5
12.Which of the following is a library routine used to generate random numbers in Python?
Easy
Arandom.randint()
Brandom.randomint()
Crandint()
Drandom.int()
13.A program uses a variable 'Total' to add up prices entered by the user. Initially, Total is set to 0. Which of the following correctly updates Total inside a loop that runs 10 times?
Medium
ATotal ← Total + Price
BTotal ← Price + 1
CTotal ← Total + 1
DTotal ← Price
14.What is the value of 'Result' after the following pseudocode is executed?
Result ← 0
FOR X ← 1 TO 4
Result ← Result + X×2
NEXT X
Medium
A20
B10
C16
D12
15.The following pseudocode uses a function. What is the output?
FUNCTION Calc(N: INTEGER) RETURNS INTEGER
IF N = 0 THEN
RETURN 1
ELSE
RETURN N×Calc(N - 1)
ENDIF
ENDFUNCTION
OUTPUT Calc(3)
Hard
A6
B3
C9
D1
16.Which of the following is the correct pseudocode to check if the variable 'Age' is between 13 and 19 inclusive?
Easy
AIF Age ≥ 13 AND Age ≤ 19 THEN
BIF Age > 13 AND Age < 19 THEN
CIF Age ≥ 13 OR Age ≤ 19 THEN
DIF Age = 13 TO 19 THEN
17.A program uses a WHILE loop to read temperatures until a value of -1 is entered. Which pseudocode correctly implements this?
Medium
AINPUT Temperature
WHILE Temperature <> -1 DO
PROCESS Temperature
INPUT Temperature
ENDWHILE
BWHILE Temperature <> -1 DO
INPUT Temperature
PROCESS Temperature
ENDWHILE
CREPEAT
INPUT Temperature
PROCESS Temperature
UNTIL Temperature = -1
DFOR X ← 1 TO 100
INPUT Temperature
IF Temperature = -1 THEN EXIT
PROCESS Temperature
NEXT X
18.The table shows the results of a survey. Which pseudocode correctly calculates the total number of people who chose 'Yes'?
Response: Yes, No, Yes, Yes, No, Yes
Hard
ACount ← 0
FOR Each Response
IF Response = 'Yes' THEN
Count ← Count + 1
ENDIF
NEXT
OUTPUT Count
BCount ← 0
FOR Each Response
Count ← Count + 1
NEXT
OUTPUT Count
CTotal ← 0
FOR Each Response
IF Response = 'Yes' THEN
Total ← Total + Response
ENDIF
NEXT
OUTPUT Total
DCount ← 1
FOR Each Response
IF Response = 'Yes' THEN
Count ← Count + 1
ENDIF
NEXT
OUTPUT Count
19.What is the purpose of the DIV operator in pseudocode?
Easy
AIt returns the integer part of a division (quotient)
BIt returns the remainder of a division
CIt performs floating-point division
DIt multiplies two numbers
20.What is the output of the following pseudocode?
Word ← 'Computer'
OUTPUT SUBSTRING(Word, 4, 3)
Medium
Aput
Bomp
Cute
DCom
21.A program uses the following pseudocode. What is the value of 'Total' after execution?
Total ← 0
FOR X ← 1 TO 3
FOR Y ← 1 TO 2
Total ← Total + X×Y
NEXT Y
NEXT X
Hard
A18
B12
C24
D36
22.Which of the following is a valid declaration of a constant in pseudocode?
Medium
ACONSTANT π ← 3.142
BCONSTANT π = 3.142
Cπ ← 3.142
DDECLARE π : CONSTANT ← 3.142
23.What is the most appropriate data type for storing a person's name?
Easy
ASTRING
BCHAR
CREAL
DBOOLEAN
24.The following pseudocode is intended to output the largest of three numbers. Which line contains an error?
01 INPUT A
02 INPUT B
03 INPUT C
04 IF A > B THEN
05 IF A > C THEN
06 OUTPUT A
07 ELSE
08 OUTPUT B
09 ENDIF
10 ELSE
11 IF B > C THEN
12 OUTPUT B
13 ELSE
14 OUTPUT C
15 ENDIF
16 ENDIF
Hard
ALine 08
BLine 04
CLine 11
DLine 14
25.A program uses a variable 'Count' to count how many numbers entered by the user are greater than 10. The program inputs 20 numbers. Which pseudocode correctly implements this?
Medium
ACount ← 0
FOR X ← 1 TO 20
INPUT Num
IF Num > 10 THEN Count ← Count + 1
ENDIF
NEXT X
OUTPUT Count
BCount ← 0
FOR X ← 1 TO 20
INPUT Num
IF Num > 10 THEN Count ← Count + Num
ENDIF
NEXT X
OUTPUT Count
CCount ← 0
FOR X ← 1 TO 20
INPUT Num
IF Num > 10 THEN Count ← Count + 1
ENDIF
OUTPUT Count
NEXT X
DCount ← 1
FOR X ← 1 TO 20
INPUT Num
IF Num > 10 THEN Count ← Count + 1
ENDIF
NEXT X
OUTPUT Count
26.What is the output of the following pseudocode?
Total ← 0
FOR X ← 1 TO 4
FOR Y ← 1 TO X
Total ← Total + Y
NEXT Y
NEXT X
OUTPUT Total
Hard
A20
B10
C30
D15
27.Which of the following is the correct pseudocode to declare a constant for the value of VAT (20%)?
Easy
ACONSTANT VAT ← 20
BCONSTANT VAT = 20
CDECLARE VAT : CONSTANT ← 20
DVAT ← 20
28.What is the value of Result after executing the following pseudocode?
Result ← 0
FOR X ← 1 TO 5
IF X MOD 2 = 0 THEN
Result ← Result + X
ENDIF
NEXT X
Medium
A6
B9
C15
D0
29.Which of the following correctly describes the difference between a function and a procedure?
Medium
AA function returns a value; a procedure does not.
BA procedure returns a value; a function does not.
CA function can only be called once; a procedure can be called multiple times.
DA procedure can take parameters; a function cannot.
30.A program contains the following pseudocode:
FUNCTION Check(N : INTEGER) RETURNS BOOLEAN
IF N < 0 THEN
RETURN True
ELSE
RETURN False
ENDIF
ENDFUNCTION
What is the output of:
OUTPUT Check(5 - 7)
Hard
ATrue
BFalse
C5
DError
31.Which data type should be used to store the value 'a'?
Easy
ACHAR
BSTRING
CINTEGER
DBOOLEAN
32.What is the output of the following pseudocode?
Word ← 'Programming'
OUTPUT SUBSTRING(Word, 5, 4)
Medium
Agram
Bramm
CProg
Dming
33.A program uses the following pseudocode to calculate the average of numbers entered. The user enters numbers until they enter 0. Which pseudocode correctly implements this?
Hard
ATotal ← 0
Count ← 0
INPUT Num
WHILE Num <> 0 DO
Total ← Total + Num
Count ← Count + 1
INPUT Num
ENDWHILE
IF Count > 0 THEN
OUTPUT Total / Count
ENDIF
BTotal ← 0
Count ← 0
INPUT Num
WHILE Num <> 0 DO
Total ← Total + Num
Count ← Count + 1
ENDWHILE
OUTPUT Total / Count
CTotal ← 0
Count ← 0
INPUT Num
WHILE Num <> 0 DO
Total ← Total + Num
INPUT Num
Count ← Count + 1
ENDWHILE
OUTPUT Total / Count
DTotal ← 0
Count ← 0
REPEAT
INPUT Num
Total ← Total + Num
Count ← Count + 1
UNTIL Num = 0
OUTPUT Total / Count
34.Which Boolean operator returns True only when both conditions are False?
Easy
ANOT (A OR B)
BA AND B
CA OR B
DNOT A AND NOT B
35.What is the value of Result after executing the following pseudocode?
Result ← 27 DIV 4
Medium
A6
B7
C3
D6.75
36.Which of the following pseudocode statements correctly generates a random integer between 10 and 20 inclusive?
Hard
ARANDOM(10, 20)
BRANDOM(10, 21)
CRANDOM()×10 + 10
DROUND(RANDOM()×10 + 10, 0)
37.Which of the following is the correct pseudocode to declare a constant named π with value 3.142?
Easy
ACONSTANT π ← 3.142
BDECLARE π : REAL ← 3.142
Cπ ← 3.142
DCONSTANT π = 3.142
38.Which of the following data types would be most appropriate to store the value 'True'?
Easy
AINTEGER
BBOOLEAN
CSTRING
DCHAR
39.What is the output of the following pseudocode?
X ← 5
Y ← 10
IF X > Y THEN
OUTPUT X
ELSE
OUTPUT Y
ENDIF
Medium
A5
B10
CX
DY
40.What is the value of Result after executing the following pseudocode?
Result ← 0
FOR X ← 1 TO 4
Result ← Result + X
NEXT X
Medium
A4
B10
C16
D24
Unlock all 40 questions & more
Buat akun gratis untuk melihat setiap soal, slide, kartu flash, dan catatan ulasan topik ini.