Multiplication tables: Difference between revisions

m
Line 1,765:
===VAX FORTRAN===
<lang Fortran>
PROGRAM TIMES
IMPLICIT NONE
C
Line 1,771:
C when in primary school. Only print the top half triangle of products.
C
C 23 Nov 15 - 0.1 - Adapted from original for VAX FORTRAN - MEJT
INTEGER I,J,K
C
CHARACTER*32 S
INTEGER I,J,K ! Counters.
CHARACTER*32 S ! Buffer for format specifier.
C
K=12
Line 1,778 ⟶ 1,780:
WRITE(S,1) K,K
1 FORMAT(8H(4H0 |,,I2.2,11HI4,/,4H --+,I2.2,9H(4H----)))
WRITE(6,S) (I,I = 1,K) ! Print heading.
C
DO 3 I=1,K
DO 3 I=1,K ! Step down the lines.
WRITE(S,2) (I-1)*4+1,K
WRITE(S,2) (I-1)*4+1,K ! Update format string.
2 FORMAT(8H(I3,1H|,,I2.2,5HX,I3,,I2.2,3HI4),12X)
2 FORMAT(12H(1H ,I2,1H|,,I2.2,5HX,I3,,I2.2,3HI4),8X) ! Format string includes an explicit carridge control character.
WRITE(6,S) I,(I*J, J = I,K)
WRITE(6,S) I,(I*J, J = I,K) ! Use format to print row with leading blanks, unused fields are ignored.
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. The number of rows and columns can also be altered by modifying the value of K which must be in the range 1 - 25.
 
=={{header|Go}}==
<lang go>
Anonymous user