1. Home
  2. /
  3. Algol
  4. /
  5. Counter and Theme Toggle

Counter and Theme Toggle - Algol Typing CST Test

Loading…

Counter and Theme Toggle — Algol Code

Demonstrates a simple counter with theme toggling using ALGOL-style structured programming.

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

Algol Language Guide

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.

Primary Use Cases

  • ▸Scientific computations
  • ▸Algorithm description in publications
  • ▸Academic teaching of programming and algorithms
  • ▸Mathematical modeling
  • ▸Compiler research and language design

Notable Features

  • ▸Block-structured programming
  • ▸Nested procedures and lexical scoping
  • ▸Call by name and call by value parameter passing
  • ▸Structured control flow: if, for, while
  • ▸Formal syntax specification (BNF)

Origin & Creator

Developed in 1958-1960 by a committee of European and American computer scientists, including Friedrich L. Bauer, John Backus, and Peter Naur.

Industrial Note

ALGOL was the standard language for publishing algorithms in scientific literature for decades and shaped the syntax and structure of many subsequent languages.

More Algol Typing Exercises

ALGOL Fibonacci SequenceALGOL Factorial CalculatorALGOL Prime CheckerALGOL Sum of ArrayALGOL Reverse StringALGOL Multiplication TableALGOL Temperature ConverterALGOL Simple Alarm SimulationALGOL Random Walk Simulation

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher