28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

*Execution error -- x MOD is not permitted<br />

The definition of the operator MOD states that it shall be an error if in an<br />

expression of the form: i MOD j the value of j is less than or equal to zero.<br />

PROGRAM error(output);<br />

VAR i, j, k : integer;<br />

BEGIN<br />

i := 123;<br />

j := -1;<br />

k := i MOD j; (wrong}<br />

writeln('Error not detected');<br />

END.<br />

*Execution error -- zero or negative argument for logarithm<br />

The mathematical function LN (logarithm to base 'e') is not defined for<br />

arguments less than or equal to zero.<br />

PROGRAM error(output);<br />

VAR j : integer;<br />

: real;<br />

BEGIN<br />

FOR j := 5 DOWNTO -5 DO<br />

:= LN(j); (should fail)<br />

writeln('Error not detected');<br />

END.<br />

*Execution error -- negative argument for square root<br />

The mathemetical function SQRT (square root) is not defined for<br />

arguments less than zero.<br />

PROGRAM error(output);<br />

VAR j : integer;<br />

r : real;<br />

BEGIN<br />

FOR j := 5 DOWNTO -5 DO<br />

r := SQRT(j); (should fail}<br />

writeln('Error not detected');<br />

END.<br />

104 <strong>Pascal</strong> Issue 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!