Sha256: 198255cb3474d6141dd00bb58b572425bfe300b07b2be70bca69c8c1e8d8a791

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

Works with Gardens Point Component Pascal

MODULE Arithmetic;
IMPORT CPmain,Console,RTS;

VAR
   x,y	  : INTEGER;
   arg	  : ARRAY 128 OF CHAR;
   status : BOOLEAN;
   

PROCEDURE Error(IN str : ARRAY OF CHAR);
BEGIN
   Console.WriteString(str);Console.WriteLn;
   HALT(1)
END Error;


BEGIN
   IF CPmain.ArgNumber() < 2 THEN Error("Give me two integers!") END;
   CPmain.GetArg(0,arg); RTS.StrToInt(arg,x,status);
   IF ~status THEN Error("Can't convert 	'"+arg+"' to Integer") END;
   CPmain.GetArg(1,arg); RTS.StrToInt(arg,y,status);
   IF ~status THEN Error("Can't convert '"+arg+"' to Integer") END;
   Console.WriteString("x + y >");Console.WriteInt(x + y,6);Console.WriteLn;
   Console.WriteString("x - y >");Console.WriteInt(x - y,6);Console.WriteLn;
   Console.WriteString("x * y >");Console.WriteInt(x * y,6);Console.WriteLn;
   Console.WriteString("x / y >");Console.WriteInt(x DIV y,6);Console.WriteLn;
   Console.WriteString("x MOD y >");Console.WriteInt(x MOD y,6);Console.WriteLn;
END Arithmetic.

command: <i>cprun Arithmetic 12 23</i><br/>

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/component_pascal.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/component_pascal.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/component_pascal.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/component_pascal.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/component_pascal.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/component_pascal.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/component_pascal.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/component_pascal.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/component_pascal.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/component_pascal.txt