Category : Modula II Source Code
Archive   : M2TUTOR.ZIP
Filename : INTMATH.MOD

 
Output of file : INTMATH.MOD contained in archive : M2TUTOR.ZIP
(* Chapter 3 - Program 2 *)
MODULE IntMath;

FROM InOut IMPORT WriteLn, WriteString, WriteInt;

VAR IntSum, IntDif, IntMul, IntDiv, IntRem : INTEGER;
A, B : INTEGER;

BEGIN
A := 9; (* Simple assignment *)
B := A + 4; (* Addition *)
IntSum := A + B; (* Addition *)
IntDif := A - B; (* Subtraction *)
IntMul := A * B; (* Multiplication *)
IntDiv := B DIV A; (* Integer division, the result is a
truncated integer number. *)
IntRem := B MOD A; (* d is the remainder of the integer
division. *)
A := (A + B) DIV (3*B + 7); (* Composite math statement *)

WriteString("The integer values are ");
WriteInt(IntSum,6);
WriteInt(IntDif,6);
WriteInt(IntMul,6);
WriteInt(IntDiv,6);
WriteInt(IntRem,6);
WriteLn;

INC(A); (* This increments the value of A *)
DEC(A); (* This decrements the value of A *)
INC(A,3); (* This adds 3 to the value of A *)
DEC(A,7); (* This reduces the value of A by 7 *)
INC(A,B*2+4); (* A composite incrementing amount *)

A := MIN(INTEGER); (* This produces the smallest INTEGER *)
B := MAX(INTEGER); (* This produces the largest INTEGER *)

END IntMath.




(* Result of execution

The integer values are 22 -4 117 1 4

*)



  3 Responses to “Category : Modula II Source Code
Archive   : M2TUTOR.ZIP
Filename : INTMATH.MOD

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/