24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>Language</strong> <strong>Reference</strong><br />

2.50 Arithmetic IF Statement<br />

<br />

IF (e) s1, s2, s3<br />

where:<br />

e<br />

is an integer, real, or double precision expression.<br />

s1, s2, s3 are statement labels of executable statements that appear in the same program unit<br />

as the arithmetic IF statement.<br />

The expression e is evaluated and if the value is less than zero then transfer is made to the statement<br />

identified by label s1. If the value is equal to zero then transfer is made to the statement identified by<br />

label s2. If the value is greater than zero then transfer is made to the statement identified by label s3.<br />

Example:<br />

IF( SIN( X ) ) 10, 20, 30<br />

10 PRINT *, ’SIN(X) IS < 0’<br />

GO TO 40<br />

20 PRINT *, ’SIN(X) = 0’<br />

GO TO 40<br />

30 PRINT *, ’SIN(X) > 0’<br />

40 CONTINUE<br />

The above example evaluates the sine of the real variable X and prints whether the result is less than 0,<br />

equal to 0, or greater than 0.<br />

The same label may appear more than once in the arithmetic IF statement.<br />

Example:<br />

IF( SIN( X ) ) 10, 10, 30<br />

10 PRINT *, ’SIN(X) IS 0’<br />

40 CONTINUE<br />

The above example evaluates the sine of the real variable X and prints whether the result is less than or<br />

equal to zero, or that it is greater than 0.<br />

84 Arithmetic IF Statement

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

Saved successfully!

Ooh no, something went wrong!