Output
OUTPUT "Welcome" OUTPUT "Age: ", Age
The Cambridge pseudocode layout for every Paper 2 topic.
OUTPUT "Welcome" OUTPUT "Age: ", Age
OUTPUT "Enter your age" INPUT Age
Total ← 0
// Comments help people read the code
INTEGER // whole number: 25 REAL // decimal number: 3.75 CHAR // one character: 'A' STRING // text: "Hello" BOOLEAN // TRUE or FALSE
DECLARE Age : INTEGER DECLARE Price : REAL DECLARE Grade : CHAR DECLARE Name : STRING DECLARE Passed : BOOLEAN CONSTANT Pi ← 3.142
+ // add - // subtract * // multiply / // divide ^ // power MOD(10, 3) // remainder: 1 DIV(10, 3) // quotient: 3
= // equal to <> // not equal to < // less than <= // less or equal > // greater than >= // greater or equal
AND // both are true OR // either is true NOT // reverses it
IF Age >= 18
THEN
OUTPUT "Adult"
ENDIFIF Age >= 18
THEN
OUTPUT "Adult"
ELSE
OUTPUT "Child"
ENDIFCASE OF Choice 1 : OUTPUT "One" 2 : OUTPUT "Two" OTHERWISE OUTPUT "Error" ENDCASE
IF Age >= 18
THEN
OUTPUT "Adult"
ELSE
IF Age >= 13
THEN
OUTPUT "Teenager"
ELSE
OUTPUT "Child"
ENDIF
ENDIFFOR Count ← 1 TO 10 OUTPUT Count NEXT Count
Count ← 1 WHILE Count <= 10 DO OUTPUT Count Count ← Count + 1 ENDWHILE
Count ← 1 REPEAT OUTPUT Count Count ← Count + 1 UNTIL Count > 10
FOR Count ← 2 TO 10 STEP 2 OUTPUT Count // 2, 4, 6, 8, 10 NEXT Count FOR Count ← 10 TO 1 STEP -1 OUTPUT Count // 10, 9, ... 1 NEXT Count
This topic is part of the Paper 2 plan. Basics, Selection and Loops are free for everyone.
This topic is part of the Paper 2 plan. Basics, Selection and Loops are free for everyone.
This topic is part of the Paper 2 plan. Basics, Selection and Loops are free for everyone.
This topic is part of the Paper 2 plan. Basics, Selection and Loops are free for everyone.
This topic is part of the Paper 2 plan. Basics, Selection and Loops are free for everyone.
Prepared by Miss Huma Imran