Skip to content

9618 · 11.1

Programming Basics — practice questions

Practice and worked examples for 9618 Programming Basics. Short previews only — attempt the full question in MarkScheme against the official scheme.

Worked example 1

A program needs to store a student's name, their score in a test out of 100, and whether they have passed. The pass mark is fixed at 50. Write pseudocode to declare appropriate variables and a constant, and then assign the following example values: Name is 'Ben', score is 78, and they have passed.

Show solution outline

// 1. Declare the constant for the pass mark CONSTANT PassMark : INTEGER = 50

// 2. Declare the variables needed DECLARE StudentName : STRING DECLARE TestScore : INTEGER DECLARE HasPassed : BOOLEAN

// 3. Assign the given values StudentName <- "Ben" TestScore <- 78

// 4. Determine the value for HasPassed based on the score // (This uses a comparison, which will be covered in more detail later) IF TestScore >= PassMark THEN HasPassed <- TRUE ELSE HasPassed <- FALSE ENDIF

// For this specific question, we can directly assign TRUE as 78 >= 50 HasPassed <- TRUE

Worked example 2

A program for a small shop needs to calculate the final price of an item. It must store the item's name, its price before tax, the VAT rate (fixed at 20%), and the final calculated price. Write pseudocode to declare these, and then calculate the final price for an item named "USB Cable" that costs £5.50 before tax.

Show solution outline

// 1. Declare the constant for the VAT rate CONSTANT VAT_RATE : REAL = 0.20

// 2. Declare the variables for the item details DECLARE ItemName : STRING DECLARE PriceExVAT : REAL DECLARE FinalPrice : REAL

// 3. Assign the initial known values ItemName <- "USB Cable" PriceExVAT <- 5.50

// 4. Perform the calculation and assign the result // The VAT amount is PriceExVAT * VAT_RATE // The final price is the original price plus the VAT amount // This can be simplified to PriceExVAT * (1 + VAT_RATE) FinalPrice <- PriceExVAT * (1 + VAT_RATE)

// After this line, FinalPrice would hold the value 5.50 * 1.20 = 6.60