Modula-2 Dice Roller - Modula2 Typing CST Test
Loading…
Modula-2 Dice Roller — Modula2 Code
Rolls a six-sided dice three times.
MODULE DiceRoll;
IMPORT InOut;
VAR i, roll: INTEGER;
BEGIN
FOR i := 1 TO 3 DO
roll := RANDOM(6) + 1;
InOut.WriteString("Roll "); InOut.WriteInt(i,0); InOut.WriteString(": "); InOut.WriteInt(roll,0); InOut.WriteLn;
END;
END DiceRoll.Modula2 Language Guide
Modula-2 is a statically typed, modular, procedural programming language designed for systems programming and teaching structured programming concepts, created as a successor to Pascal.
Primary Use Cases
- ▸Teaching structured and modular programming
- ▸Systems programming and embedded applications
- ▸Operating system and compiler development
- ▸Prototyping modular software architectures
- ▸Applications requiring strong type safety
Notable Features
- ▸Module system for encapsulation
- ▸Strong static typing
- ▸Procedural programming with structured control
- ▸Separate compilation for modules
- ▸Support for low-level systems programming
Origin & Creator
Developed by Niklaus Wirth in 1978 at ETH Zurich as a follow-up to Pascal, focusing on modularity and systems programming.
Industrial Note
Modula-2 found niche use in teaching programming concepts, embedded systems, and certain early OS development projects, though modern usage is mostly academic.