Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views3 pages

PSEUOCODEPRACTICE

The document provides examples of pseudocode for various programming tasks suitable for A-Level Computer Science (9618). It includes examples for multiplying numbers, checking conditions, mapping numbers to colors, counting even numbers, calculating averages, sorting numbers, and summing values until a negative number is entered. Each example demonstrates basic programming concepts and control structures in pseudocode format.

Uploaded by

Mr Saem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

PSEUOCODEPRACTICE

The document provides examples of pseudocode for various programming tasks suitable for A-Level Computer Science (9618). It includes examples for multiplying numbers, checking conditions, mapping numbers to colors, counting even numbers, calculating averages, sorting numbers, and summing values until a negative number is entered. Each example demonstrates basic programming concepts and control structures in pseudocode format.

Uploaded by

Mr Saem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PSEUOCODE PRACTICE A-LEVEL CS 9618

Example 1: Multiply Two Numbers

arduino
CopyEdit
OUTPUT "Enter first number:"
INPUT Number1
OUTPUT "Enter second number:"
INPUT Number2
Product ← Number1 * Number2
OUTPUT "The product is:", Product

Example 2: Check if Number is Not 5 or 6

OUTPUT "Enter a number:"


INPUT Number
IF Number ≠ 5 AND Number ≠ 6 THEN
OUTPUT "The number you entered is not a 5 or a 6."
ELSE
OUTPUT "You entered a 5 or a 6."
ENDIF

Example 3: Number to Color Mapping

OUTPUT "Enter a number:"


INPUT Number
IF Number > 0 AND Number ≤ 10 THEN
OUTPUT "blue"
ELSE IF Number > 10 AND Number ≤ 20 THEN
OUTPUT "red"
ELSE IF Number > 20 AND Number ≤ 30 THEN
OUTPUT "green"
ELSE
OUTPUT "It is not a correct color option."
ENDIF

Example 4: Multiples of 5 from 1 to 100

mathematica
CopyEdit
FOR Count ← 1 TO 100 DO
IF Count MOD 5 = 0 THEN
OUTPUT Count
ENDIF
NEXT Count
PSEUOCODE PRACTICE A-LEVEL CS 9618
Example 5: Count Even Numbers Up to User-Defined Limit

OUTPUT "Enter the stopping point:"


INPUT StopPoint
CountEven ← 0
FOR Number ← 1 TO StopPoint DO
IF Number MOD 2 = 0 THEN
CountEven ← CountEven + 1
ENDIF
NEXT Number
OUTPUT "The total number of even numbers is:", CountEven

Example 6: Average, Minimum, and Maximum of 5 Numbers

DECLARE Numbers[5]
Sum ← 0
FOR i ← 0 TO 4 DO
OUTPUT "Enter number:", i+1
INPUT Numbers[i]
Sum ← Sum + Numbers[i]
NEXT i

Average ← Sum / 5
Min ← Numbers[0]
Max ← Numbers[0]

FOR i ← 1 TO 4 DO
IF Numbers[i] < Min THEN
Min ← Numbers[i]
ENDIF
IF Numbers[i] > Max THEN
Max ← Numbers[i]
ENDIF
NEXT i

OUTPUT "The average is:", Average


OUTPUT "The smallest number is:", Min
OUTPUT "The largest number is:", Max

Homework 1: Sort Three Numbers


OUTPUT "Enter first number:"
INPUT Num1
OUTPUT "Enter second number:"
INPUT Num2
OUTPUT "Enter third number:"
INPUT Num3

IF Num1 > Num2 THEN


Temp ← Num1
Num1 ← Num2
Num2 ← Temp
ENDIF

IF Num2 > Num3 THEN


Temp ← Num2
Num2 ← Num3
PSEUOCODE PRACTICE A-LEVEL CS 9618
Num3 ← Temp
ENDIF

IF Num1 > Num2 THEN


Temp ← Num1
Num1 ← Num2
Num2 ← Temp
ENDIF

OUTPUT "The numbers in sorted order are:", Num1, Num2, Num3

Homework 2: Running Sum Until Negative Number


mathematica
CopyEdit
Sum ← 0
REPEAT
OUTPUT "Enter a number:"
INPUT Number
IF Number >= 0 THEN
Sum ← Sum + Number
ENDIF
UNTIL Number < 0
OUTPUT "The final sum is:", Sum

You might also like