A Little Fortran
For Chapter 6, Problem 8.
FORTRAN | EXPANSION | |||
|
(X has some initial value prior to entering the loop.)
A = 1 IF A > 3 THEN EXIT X = X + 1 A = A + 1 (A now equals 2) IF A > 3 THEN EXIT X = X + 1 A = A + 1 (A now equals 3) IF A > 3 THEN EXIT X = X + 1 A = A + 1 (A now equals 4) IF A > 3 THEN EXIT EXIT
|
For Chapter 6, Problem 10.
FORTRAN | MEANING |
READ *, X | Read the next input record from the standard input device
and place the results into variable X.
The asterisk occupies the position that belongs to a number than identifies an input or output device. |
IF (X .EQ. 0) Y(I) = 0
IF (X .NE. 0) Y(I) = 10 |
Y(I) is the I-th element of array Y.
An array is a set of contiguous data elements that are referred to by a common name. In this example, the array name is Y. Elements of an array are located by an index. The index is a number. In this example, the index is I. In the IF statements, the relational operator .EQ. means "equal", and the relational operator .NE. means "not equal". A BASIC version of these statements: IF X = 0 THEN Y(I) = 0 IF X <> 0 THEN Y(I) = 10 |