Multiplication tables: Difference between revisions

Line 1,763:
READ(in,"(I2,<N>I4)") N,(A(I),I = 1,N)
would read N as a two-digit integer, and, as the READ statement executes further, use that value of N both in the FORMAT text's interpretation and in the further processing of the READ statement.
===VAX FORTRAN===
<lang Fortran>
PROGRAM TIMES
IMPLICIT NONE
C
C Produce a formatted multiplication table of the kind memorised by rote
C when in primary school. Only print the top half triangle of products.
C
INTEGER I,J,K
CHARACTER*32 S
C
K=12
C
WRITE(S,1) K,K
1 FORMAT(8H(4H0 |,,I2.2,11HI4,/,4H --+,I2.2,9H(4H----)))
WRITE(6,S) (I,I = 1,K)
DO 3 I=1,K
WRITE(S,2) (I-1)*4+1,K
2 FORMAT(8H(I3,1H|,,I2.2,5HX,I3,,I2.2,3HI4),12X)
WRITE(6,S) I,(I*J, J = I,K)
3 CONTINUE
C
END
</lang>Based on the above code but with a slight modification as VAX FORTRAN doesn't allow zero width fields in a format statement.
 
=={{header|Go}}==
Anonymous user