0% found this document useful (0 votes)
12 views4 pages

Pseudocode Practice Examples

The document contains basic programming scenario questions formatted for IGCSE practice, including examples for checking even/odd numbers, determining positive/negative/zero, finding the largest of three numbers, and calculating the square of a number. It also covers a simple grading system, checks for multiples of 5, calculates the area of a rectangle, and verifies voting eligibility based on age. Additionally, it includes string manipulation examples and methods to find the largest and smallest numbers from multiple inputs, as well as calculating totals and averages.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Pseudocode Practice Examples

The document contains basic programming scenario questions formatted for IGCSE practice, including examples for checking even/odd numbers, determining positive/negative/zero, finding the largest of three numbers, and calculating the square of a number. It also covers a simple grading system, checks for multiples of 5, calculates the area of a rectangle, and verifies voting eligibility based on age. Additionally, it includes string manipulation examples and methods to find the largest and smallest numbers from multiple inputs, as well as calculating totals and averages.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

Basic Scenario Questions for practice:

This matches exactly the IGCSE format you shared:


• Keywords (INPUT, OUTPUT, IF, THEN, ELSE, ENDIF) are in CAPITALS.
• Meaningful names (like Number) start with a capital letter.
• Indentation (two spaces under IF/ELSE paths) is maintained.
• Assignment operator ← is not needed here because we are only reading and checking the
number.
• MOD operator is used to check remainder (even/odd check).

Display even or odd


• If the number is even, it outputs "Even Number".
• If the number is odd, it outputs "Odd Number".

DECLARE Number : INTEGER


OUTPUT "Enter a number"
INPUT Number
IF MOD(Number, 2) = 0
THEN
OUTPUT "Even number"
ELSE
OUTPUT "Odd number"
ENDIF

Check if a number is positive, negative, or zero


OUTPUT "Enter a number" THEN
INPUT Number OUTPUT "Negative Number"
IF Number > 0 ELSE
THEN OUTPUT "Zero"
OUTPUT "Positive Number" ENDIF
ELSE ENDIF
IF Number < 0

2. Find the larger of three numbers


DECLARE Number1 : INTEGER THEN
DECLARE Number2 : INTEGER OUTPUT "First number is the largest"
DECLARE Number3 : INTEGER ELSE
IF Number2 >= Number3
OUTPUT "Enter first number" THEN
INPUT Number1 OUTPUT "Second number is the largest"
OUTPUT "Enter second number" ELSE
INPUT Number2 OUTPUT "Third number is the largest"
OUTPUT "Enter third number" ENDIF
INPUT Number3 ENDIF

IF Number1 >= Number2 AND Number1 >=


Number3
2

3. Calculate and display the square of a number


OUTPUT "Enter a number"
INPUT Number
Square ← Number ^ 2
OUTPUT "The square is ", Square

4. Simple grading system


OUTPUT "Enter marks" ELSE
INPUT Marks IF Marks >= 70
IF Marks >= 90 THEN
THEN OUTPUT "Grade C"
OUTPUT "Grade A" ELSE
ELSE OUTPUT "Fail"
IF Marks >= 80 ENDIF
THEN ENDIF
OUTPUT "Grade B" ENDIF

5. Display whether a number is multiple of 5


OUTPUT "Enter a number" OUTPUT "Multiple of 5"
INPUT Number ELSE
IF MOD(Number,5) = 0 OUTPUT "Not a multiple of 5"
THEN ENDIF

Calculate area of a rectangle


DECLARE Length : REAL OUTPUT "Enter width"
DECLARE Width : REAL INPUT Width
DECLARE Area : REAL Area ← Length * Width
OUTPUT "Enter length" OUTPUT "Area is ", Area
INPUT Length

3. Check if age is eligible to vote


DECLARE Age : INTEGER OUTPUT "Eligible to vote"
OUTPUT "Enter your age" ELSE
INPUT Age OUTPUT "Not eligible to vote"
IF Age >= 18 ENDIF
THEN

Calculate total and average of three marks


DECLARE Mark1 : INTEGER INPUT Mark2
DECLARE Mark2 : INTEGER OUTPUT "Enter third mark"
DECLARE Mark3 : INTEGER INPUT Mark3
DECLARE Total : INTEGER
DECLARE Average : REAL Total ← Mark1 + Mark2 + Mark3
Average ← Total / 3
OUTPUT "Enter first mark"
INPUT Mark1 OUTPUT "Total marks: ", Total
OUTPUT "Enter second mark" OUTPUT "Average marks: ", Average
3

String Variables:
Greet the user by name
DECLARE Name : STRING

OUTPUT "Enter your name"


INPUT Name

OUTPUT "Hello, ", Name

Join (concatenate) two strings


DECLARE FirstName : STRING
DECLARE LastName : STRING
DECLARE FullName : STRING

OUTPUT "Enter your first name"


INPUT FirstName
OUTPUT "Enter your last name"
INPUT LastName

FullName ← FirstName + " " + LastName


OUTPUT "Your full name is ", FullName

Check if a password is correct

DECLARE Pword1, Pword2 : STRING

OUTPUT "Enter password"


INPUT Pword1
OUTPUT "Re-enter the same password."
INPUT Pword2

IF Pword1 = Pword2
THEN
OUTPUT "Access granted"
ELSE
OUTPUT "Access denied"
ENDIF
Find the largest/maximum number from from 10 inputs
Largest <- 0
Largest <- 0
Largest <- 0
Count <- 1
Count <- 1
FOR Count <- 1 TO 10
WHILE Count <= 10
REPEAT
INPUT Number
INPUT Number
INPUT Number
IF Number > Largest
IF Number > Largest
IF Number > Largest
THEN
THEN
THEN
Largest <- Number
ENDIF Largest <- Number
Largest <- Number ENDIF
ENDIF
NEXT Count
Count <- Count + 1
Count <- Count + 1
OUTPUT Largest
ENDWHILE
UNTIL Count<11
OUTPUT Largest
OUTPUT Largest

Find the smallest/minimum number from from 10 inputs


Smallest <- 9999
Smallest <- 9999
Smallest <- 9999
Count <- 1
Count <- 1
FOR Count <- 1 TO 10
WHILE Count <= 10
REPEAT
INPUT Number
INPUT Number
INPUT Number
IF Number < Smallest
IF Number < Smallest
IF Number < Smallest
THEN
THEN
THEN
Smallest <- Number
ENDIF Smallest <- Number
Smallest <- Number ENDIF
ENDIF
NEXT Count
Count <- Count + 1
Count <- Count + 1
OUTPUT Smallest
ENDWHILE
UNTIL Count<11
OUTPUT Smallest
OUTPUT Smallest

Calculate total and average of 10 inputs


DECLARE Mark : INTEGER
DECLARE Total : INTEGER
DECLARE Average : REAL

FOR Count <- 1 TO 10 Average ← Total / Count -1

OUTPUT "Enter mark" OUTPUT "Total marks: ", Total


INPUT Mark OUTPUT "Average marks: ", Average

Total ←Total + Mark

NEXT Count

You might also like