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.
Pseudocode is a rough draft for code โ write the logic in plain English first, then translate to real code.
Showing a random 20 of 50 problems.
Example 1
medium
Trace: SET x TO 20; SET steps TO 0; WHILE x > 1: SET x TO x div 2; SET steps TO steps + 1. What is steps?
Example 2
easy
Trace: SET s TO 0; FOR i FROM 1 TO 5: SET s TO s + i. What is s?
Example 3
easy
Trace: SET n TO 5; SET n TO n + 3; SET n TO n * 2. What is n at the end?
Example 4
challenge
Two pseudocode versions sum 1..n. Version X uses a FOR loop adding each i. Version Y outputs n*(n+1)/2. For n=100, do they agree, and on what value?
Example 5
easy
Which control structure repeats steps WHILE a condition stays true?
Example 6
easy
Trace: SET total TO 0; FOR i FROM 1 TO 3: SET total TO total + i. What is total at the end?FOR i FROM 1 TO 3 accumulating total
Example 7
medium
Trace nested loops: SET r TO 0; FOR i FROM 1 TO 3: FOR j FROM 1 TO 3: SET r TO r + 1. What is r?
Example 8
challenge
Trace Euclid's algorithm: SET a TO 48; SET b TO 18; WHILE b != 0: SET t TO b; SET b TO a MOD b; SET a TO t. What is a at the end?
Example 9
hard
Trace linear search: SET arr TO [3, 8, 5, 9, 2]; SET target TO 9; FOR i FROM 0 TO 4: IF arr[i] = target THEN OUTPUT i AND STOP. What is output?linear search: find index of target=9 in arr
Example 10
easy
Which keyword introduces a loop that repeats a fixed number of times in pseudocode: WHILE or FOR?
Example 11
hard
Trace: SET x TO 81; SET steps TO 0; WHILE x > 1: SET x TO x DIV 3; SET steps TO steps + 1. What is steps?
Example 12
hard
A colleague writes pseudocode that mixes Python syntax, uses unclear variable names, and skips steps. Identify three problems with: 'x = input(); for y in x: if y == z: cnt+=1; print(cnt)'. Rewrite it properly.
Example 13
medium
Trace: SET total TO 0; FOR i FROM 1 TO 6: IF i MOD 2 = 1 THEN SET total TO total + i. What is total?
Example 14
medium
What is wrong with this pseudocode for the rule 'avoid language-specific syntax': `for(int i=0;i<10;i++){total+=i;}`
Example 15
challenge
Two pseudocode versions sum 1..n. Version X loops adding each i. Version Y outputs n*(n+1)/2. For n=200, do they agree, and on what value?
Example 16
hard
Trace a swap: SET a TO 7; SET b TO 2; SET t TO a; SET a TO b; SET b TO t. What are a and b?
Example 17
hard
Trace: SET arr TO [3,1,4,1,5,9,2,6]; bubble-sort one pass swapping adjacent if out of order. Show arr after one pass.
Example 18
easy
In pseudocode, which keyword introduces a two-way decision?
Example 19
medium
Write pseudocode that asks for a password until the user enters 'secret'.WHILE password incorrect: keep asking
Example 20
easy
Trace: SET a TO 3; SET b TO 4; SET c TO a * b; OUTPUT c. What is printed?