Published by Patrick Mutisya · 14 days ago
Write pseudocode statements that:
| Category | Operator | Purpose | Example |
|---|---|---|---|
| Arithmetic | + | Addition | \$a + b\$ |
| Arithmetic | - | Subtraction | \$a - b\$ |
| Arithmetic | * | Multiplication | \$a * b\$ |
| Arithmetic | / | Division | \$a / b\$ |
| Arithmetic | mod | Modulo (remainder) | \$a \bmod b\$ |
| Logical | AND | Both conditions true | \$x \; \text{AND} \; y\$ |
| Logical | OR | At least one condition true | \$x \; \text{OR} \; y\$ |
| Logical | NOT | Negates a condition | \$\text{NOT}\; x\$ |
| Relational | =, <>, <, >, ≤, ≥ | Comparison of values | \$a \; \ge \; b\$ |
For the purposes of this syllabus the following conventions are used:
READ variable – prompts the user and stores the value.WRITE expression – displays the evaluated expression.variable ← expression.# comment text.Read two numbers, compute their sum, product and remainder, then display the results.
# Example 1
READ a
READ b
sum ← a + b
product ← a * b
remainder ← a mod b
WRITE "Sum = " + sum
WRITE "Product = " + product
WRITE "Remainder = " + remainder
Determine whether a candidate passes an eligibility test based on age and score.
# Example 2
READ age
READ score
eligible ← (age ≥ 18) AND (score ≥ 70)
WRITE "Eligibility: " + eligible
Calculate the average of three marks and decide if the student has passed.
# Example 3
READ m1
READ m2
READ m3
average ← (m1 + m2 + m3) / 3
passed ← average ≥ 50
WRITE "Average = " + average
WRITE "Passed? " + passed
Write pseudocode that reads an integer n and outputs whether n is a multiple of 5 or 7.
Write pseudocode that reads two numbers x and y, computes (x² + y²) mod 10, and displays the result.
Write pseudocode that reads a temperature in Celsius, converts it to Fahrenheit using \$F = \frac{9}{5}C + 32\$, and prints both values.