Learn Simula - 10 Code Examples & CST Typing Practice Test
Simula is a high-level, statically typed programming language designed for simulation and object-oriented programming. It introduced the concept of classes, objects, and inheritance, laying the foundation for modern object-oriented languages like C++ and Java.
Learn SIMULA with Real Code Examples
Updated Nov 21, 2025
Code Sample Descriptions
Simula Counter and Theme Toggle
BEGIN
CLASS Counter;
INTEGER count;
BOOLEAN isDark;
PROCEDURE updateUI;
BEGIN
OutText("Counter: "); OutInt(count,0); OutImage;
IF isDark THEN OutText("Theme: Dark") ELSE OutText("Theme: Light"); OutImage;
END updateUI;
PROCEDURE increment;
BEGIN
count := count + 1;
updateUI;
END increment;
PROCEDURE decrement;
BEGIN
count := count - 1;
updateUI;
END decrement;
PROCEDURE reset;
BEGIN
count := 0;
updateUI;
END reset;
PROCEDURE toggleTheme;
BEGIN
isDark := NOT isDark;
updateUI;
END toggleTheme;
END Counter;
REF(Counter) c;
c :- NEW Counter;
c.count := 0;
c.isDark := FALSE;
c.updateUI;
c.increment;
c.increment;
c.toggleTheme;
c.decrement;
c.reset;
END
Demonstrates a simple counter with theme toggling using Simula classes, objects, and procedures.
Simula Random Number Generator
BEGIN
INTEGER i, num;
FOR i := 1 STEP 1 UNTIL 3 DO
num := RANDOM(100) + 1;
OutText("Random "); OutInt(i,0); OutText(": "); OutInt(num,0); OutImage;
END;
END
Generates random numbers between 1 and 100 and prints them.
Simula Todo List
BEGIN
ARRAY todos[10]; INTEGER count;
count := 0;
PROCEDURE addTask(task);
BEGIN
todos[count] := task; count := count + 1;
OutText("Todos: "); OutInt(count,0); OutImage;
END addTask;
PROCEDURE removeTask(idx);
BEGIN
INTEGER i;
FOR i := idx STEP 1 UNTIL count-2 DO todos[i] := todos[i+1] END;
count := count - 1;
END removeTask;
addTask("Buy milk");
addTask("Write Simula code");
removeTask(0);
END
Maintains a simple todo list with add and remove functionality.
Simula Dice Roller
BEGIN
INTEGER i, roll;
FOR i := 1 STEP 1 UNTIL 3 DO
roll := RANDOM(6) + 1;
OutText("Roll "); OutInt(i,0); OutText(": "); OutInt(roll,0); OutImage;
END;
END
Rolls a six-sided dice three times.
Simula Countdown Timer
BEGIN
INTEGER count;
count := 5;
WHILE count >= 0 DO
OutText("Countdown: "); OutInt(count,0); OutImage;
count := count - 1;
END;
OutText("Done!"); OutImage;
END
Counts down from 5 to 0.
Simula Prime Checker
BEGIN
ARRAY nums[3]; nums[0]:=7; nums[1]:=10; nums[2]:=13;
INTEGER n,i; BOOLEAN isPrime;
FOR n IN nums DO
isPrime := TRUE;
FOR i := 2 STEP 1 UNTIL n-1 DO
IF n MOD i = 0 THEN isPrime := FALSE END;
END;
OutInt(n,0);
IF isPrime THEN OutText(" is Prime") ELSE OutText(" is Not Prime") END; OutImage;
END;
END
Checks if numbers are prime.
Simula Temperature Converter
BEGIN
REAL FUNCTION cToF(c); BEGIN RETURN c*9/5+32 END;
REAL FUNCTION fToC(f); BEGIN RETURN (f-32)*5/9 END;
OutText("25°C = "); OutReal(cToF(25),2); OutImage;
OutText("77°F = "); OutReal(fToC(77),2); OutImage;
END
Converts Celsius to Fahrenheit and Fahrenheit to Celsius.
Simula Shopping Cart
BEGIN
ARRAY cart[10]; ARRAY prices[10]; INTEGER count;
count := 0;
PROCEDURE addItem(item, price);
BEGIN
cart[count] := item; prices[count] := price; count := count + 1;
END addItem;
PROCEDURE removeItem(idx);
BEGIN
INTEGER i;
FOR i := idx STEP 1 UNTIL count-2 DO cart[i] := cart[i+1]; prices[i] := prices[i+1] END;
count := count - 1;
END removeItem;
addItem("Apple",2);
addItem("Banana",3);
removeItem(0);
END
Adds and removes items in a shopping cart with total cost.
Simula Name Greeting
BEGIN
PROCEDURE greet(name);
BEGIN
OutText("Hello, "); OutText(name); OutText("! Welcome!"); OutImage;
END greet;
greet("Saurav");
greet("Alice");
greet("Bob");
END
Greets users by name.
Simula Stopwatch
BEGIN
INTEGER time; time := 0;
WHILE time < 5 DO
OutText("Stopwatch: "); OutInt(time,0); OutText(" seconds"); OutImage;
time := time + 1;
END;
OutText("Done!"); OutImage;
END
Simulates a stopwatch incrementing seconds.
Frequently Asked Questions about Simula
What is Simula?
Simula is a high-level, statically typed programming language designed for simulation and object-oriented programming. It introduced the concept of classes, objects, and inheritance, laying the foundation for modern object-oriented languages like C++ and Java.
What are the primary use cases for Simula?
Discrete event simulation. Teaching object-oriented programming. Modeling complex systems. Research in programming languages. Historical study of software engineering paradigms
What are the strengths of Simula?
Pioneering object-oriented concepts. Clear modeling of real-world systems. Supports discrete event simulation natively. Strong typing ensures safer code. Educational value for understanding OO principles
What are the limitations of Simula?
Obsolete for modern production use. Limited libraries and ecosystem. Performance lower than modern compiled languages. Concurrency limited to coroutines, no modern threads. Primarily academic or historical interest today
How can I practice Simula typing speed?
CodeSpeedTest offers 10+ real Simula code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.