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