Learn Algol - 10 Code Examples & CST Typing Practice Test
ALGOL (Algorithmic Language) is a family of high-level programming languages designed for scientific computations and algorithm description, known for its structured programming features and influence on modern languages like Pascal, C, and Java.
Learn ALGOL with Real Code Examples
Updated Nov 20, 2025
Code Sample Descriptions
ALGOL Counter and Theme Toggle
begin
integer count;
boolean isDark;
count := 0;
isDark := false;
procedure updateUI;
begin
print("Counter: ", count);
print("Theme: ", if isDark then "Dark" else "Light");
end;
procedure increment;
begin
count := count + 1;
updateUI;
end;
procedure decrement;
begin
count := count - 1;
updateUI;
end;
procedure reset;
begin
count := 0;
updateUI;
end;
procedure toggleTheme;
begin
isDark := not isDark;
updateUI;
end;
comment Simulate actions;
updateUI;
increment;
increment;
toggleTheme;
decrement;
reset;
end
Demonstrates a simple counter with theme toggling using ALGOL-style structured programming.
ALGOL Fibonacci Sequence
begin
integer a, b, c, i;
a := 0;
b := 1;
print(a);
print(b);
for i := 1 step 1 until 8 do
begin
c := a + b;
print(c);
a := b;
b := c;
end;
end
Generates the first 10 Fibonacci numbers.
ALGOL Factorial Calculator
begin
integer n, f, i;
n := 5;
f := 1;
for i := 1 step 1 until n do
begin
f := f * i;
end;
print(f);
end
Calculates the factorial of a number.
ALGOL Prime Checker
begin
integer num, i;
boolean isPrime;
num := 13;
isPrime := true;
for i := 2 step 1 until num-1 do
begin
if num mod i = 0 then
begin
isPrime := false;
goto end_loop;
end;
end;
end_loop:
if isPrime then print("Prime") else print("Not Prime");
end
Checks if a number is prime.
ALGOL Sum of Array
begin
integer arr[5], sum, i;
arr[1] := 1; arr[2] := 2; arr[3] := 3; arr[4] := 4; arr[5] := 5;
sum := 0;
for i := 1 step 1 until 5 do
sum := sum + arr[i];
print(sum);
end
Calculates the sum of an integer array.
ALGOL Reverse String
begin
string s, r;
integer i;
s := "Hello";
r := "";
for i := length(s) step -1 until 1 do
r := r + s[i];
print(r);
end
Reverses a string character by character.
ALGOL Multiplication Table
begin
integer n, i;
n := 5;
for i := 1 step 1 until 10 do
print(n, " x ", i, " = ", n*i);
end
Prints multiplication table of a number.
ALGOL Temperature Converter
begin
real c, f;
c := 25.0;
f := (c * 9.0 / 5.0) + 32.0;
print(f);
end
Converts Celsius to Fahrenheit.
ALGOL Simple Alarm Simulation
begin
integer temperature, threshold;
temperature := 80;
threshold := 75;
if temperature > threshold then
print("Alarm: Temperature Too High!")
else
print("Temperature Normal");
end
Simulates an alarm when a threshold is reached.
ALGOL Random Walk Simulation
begin
integer steps, i, position;
steps := 10;
position := 0;
for i := 1 step 1 until steps do
begin
if random(2) = 0 then
position := position + 1
else
position := position - 1;
print(position);
end;
end
Simulates a 1D random walk using integers.
Frequently Asked Questions about Algol
What is Algol?
ALGOL (Algorithmic Language) is a family of high-level programming languages designed for scientific computations and algorithm description, known for its structured programming features and influence on modern languages like Pascal, C, and Java.
What are the primary use cases for Algol?
Scientific computations. Algorithm description in publications. Academic teaching of programming and algorithms. Mathematical modeling. Compiler research and language design
What are the strengths of Algol?
Introduced modern programming concepts. Structured and readable code. Strong influence on future languages. Well-suited for algorithm description. Formal language definition enables compiler development
What are the limitations of Algol?
Limited hardware and system support. Not widely used for commercial software. Variations between ALGOL 58, 60, and 68 caused portability issues. Lacked extensive standard libraries. Mostly replaced by modern languages in practice
How can I practice Algol typing speed?
CodeSpeedTest offers 10+ real Algol code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.