Modula-2 Conditional Example - Modula Typing CST Test
Loading…
Modula-2 Conditional Example — Modula Code
Checks if a number is even or odd.
# modula2/if_example.m2
MODULE EvenOdd;
IMPORT InOut;
VAR n: INTEGER;
BEGIN
n := 7;
IF n MOD 2 = 0 THEN
InOut.WriteString("Even");
ELSE
InOut.WriteString("Odd");
END;
InOut.WriteLn;
END EvenOdd.Modula Language Guide
Modula is a procedural programming language and modular systems language designed by Niklaus Wirth. It emphasizes strong typing, modularity, and simplicity, supporting the development of reliable, maintainable software systems.
Primary Use Cases
- ▸Teaching structured and modular programming
- ▸Systems and embedded programming
- ▸Research in programming languages and compilers
- ▸Developing reliable software with modular architecture
- ▸Prototyping software with clear separation of concerns
Notable Features
- ▸Module-based program structure
- ▸Strong typing with explicit type declarations
- ▸Separate compilation units for modularity
- ▸Structured control statements (loops, conditionals)
- ▸Explicit import/export mechanism for modules
Origin & Creator
Modula was created by Niklaus Wirth in 1975 at ETH Zurich as a successor to Pascal with modular programming support.
Industrial Note
Modula is preferred in contexts where strong type safety, modular design, and structured programming are valued, particularly in education and system programming.