Modula-2 Random Number Generator - Modula2 Typing CST Test
Loading…
Modula-2 Random Number Generator — Modula2 Code
Generates random numbers between 1 and 100 and prints them.
MODULE RandomGen;
IMPORT InOut;
VAR i, num: INTEGER;
BEGIN
FOR i := 1 TO 3 DO
num := RANDOM(100) + 1;
InOut.WriteString("Random "); InOut.WriteInt(i,0); InOut.WriteString(": "); InOut.WriteInt(num,0); InOut.WriteLn;
END;
END RandomGen.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.