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.84 WHILE Statement<br />

WHILE (e) stmt<br />

where:<br />

e<br />

stmt<br />

is a logical expression.<br />

is an executable statement. Only certain executable statements are allowed. See the section<br />

entitled "Classifying Statements" on page 9 at the beginning of this chapter for a list of allowed<br />

statements.<br />

This form of the WHILE statement allows an executable statement to be repeatedly executed until the<br />

logical expression e is false.<br />

Example:<br />

I = 0<br />

WHILE( I .LE. 100 ) CALL PRTSQR( I )<br />

END<br />

SUBROUTINE PRTSQR( J )<br />

PRINT *, J, J**2<br />

J = J + 1<br />

END<br />

In the above example, the subroutine PRTSQR is called again and again until the value of I has been<br />

incremented beyond 100. Note that the subroutine increments its argument thereby guaranteeing that the<br />

program will eventually stop execution.<br />

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

Statements".<br />

146 WHILE Statement

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

Saved successfully!

Ooh no, something went wrong!