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>FORTRAN</strong> Statements<br />

2.25 ELSE IF Statement<br />

<br />

ELSE IF (e) THEN<br />

where:<br />

e<br />

is a logical expression or integer arithmetic expression, in which case the result of the integer<br />

expression is compared for inequality to the integer value 0.<br />

The ELSE IF statement is used in conjunction with the IF statement. The range of the ELSE IF block<br />

is terminated by another ELSE IF statement, an ELSE statement, or an END IF statement.<br />

Example:<br />

IF( A .LT. B )THEN<br />

PRINT *, ’A is less than B’<br />

ELSE IF( A .EQ. B )THEN<br />

PRINT *, ’A is equal to B’<br />

ELSE<br />

PRINT *, ’A is greater than B’<br />

END IF<br />

Transfer of control into the range of an ELSE IF block is illegal. It is interesting to note that the ELSE<br />

IF statement may be identified by a statement label but it must not be referenced by any statement!<br />

Example:<br />

* Illegal transfer into the range of<br />

* an ELSE IF statement.<br />

IF( A .EQ. 0.0 )GO TO 110<br />

IF( A .LT. B )THEN<br />

PRINT *, ’A is less than B’<br />

ELSE IF( A .EQ. B )THEN<br />

PRINT *, ’A is equal to B or’<br />

110 PRINT *, ’A is equal to 0’<br />

ELSE<br />

PRINT *, ’A is greater than B’<br />

END IF<br />

The above is an example of an illegal attempt to branch into the range of an ELSE IF block.<br />

For more information, see the chapter entitled "Program Structure Control Statements" on page 193.<br />

ELSE IF Statement 55

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

Saved successfully!

Ooh no, something went wrong!