Pseudocode CS Thinking Example 3

Follow the full solution, then compare it with the other examples linked below.

Example 3

medium
Write pseudocode for a program that reads a list of 10 numbers and outputs how many are above average.

Solution

  1. 1
    Step 1: Read 10 numbers into an array. Calculate the sum and divide by 10 to find the average.
  2. 2
    Step 2: Loop through the array, count how many values are greater than the average, and output the count.

Answer

FOR i = 0 TO 9: numbers[i] = INPUT(). average = SUM(numbers) / 10. SET count = 0. FOR i = 0 TO 9: IF numbers[i] > average THEN count = count + 1. OUTPUT count.
This problem requires two passes through the data โ€” first to calculate the average, then to count values above it. Pseudocode makes this two-pass logic clear before coding.

About Pseudocode

An informal, human-readable description of an algorithm using structured language that resembles code but is not tied to any specific programming language. Pseudocode uses plain English mixed with programming constructs like IF, WHILE, and FOR to describe logic without worrying about syntax rules.

Learn more about Pseudocode โ†’

More Pseudocode Examples