| feature | BASIC | FORTRAN | ALGOL | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name origin | Beginner's All-purpose Symbolic Instruction Code | FORmula TRANslation | ALGOrithmic Language | ||||||||||||||||||||||||||||||||||||
| version here, computer | HP BASIC, HP | FORTRAN IV = Fortran 66, IBM | Algol-60, Burroughs 6700 | ||||||||||||||||||||||||||||||||||||
| year invented | 1964 | 1954 | 1958 | ||||||||||||||||||||||||||||||||||||
| year commerically released | 1964 | 1957 | 1960 | ||||||||||||||||||||||||||||||||||||
| inventors |
John Kemeny, Thomas Kurtz | John Backus | committee | ||||||||||||||||||||||||||||||||||||
| call by... | reference | reference | value, name | ||||||||||||||||||||||||||||||||||||
| compilers handle recursion? | (yes in modern versions) | no (except in Fortran 90) | yes | ||||||||||||||||||||||||||||||||||||
| line numbers needed? | yes | no | no | ||||||||||||||||||||||||||||||||||||
| line numbers example |
10 INPUT "Your name: "; U$ 20 PRINT "Hello "; U$ 25 REM 30 INPUT "How many: "; N 35 S$ = "" | (none) | (none) | ||||||||||||||||||||||||||||||||||||
| unconventional characters used? | no | no | yes | ||||||||||||||||||||||||||||||||||||
| unconventional characters | (none) | (none) |
up arrow horizontal divide | ||||||||||||||||||||||||||||||||||||
| identifier maximum recognition length | 2 | 6-7 | unlimited | ||||||||||||||||||||||||||||||||||||
| identifier case | all upper case | all upper case | mixed case | ||||||||||||||||||||||||||||||||||||
| identifier examples |
A I P1 N$ |
ALPHA I PI NAME |
ALPHA I PI NAME | ||||||||||||||||||||||||||||||||||||
| delimiter | ; (only if on same line) | (none) | ; | ||||||||||||||||||||||||||||||||||||
| comment |
REM REM TIC-TAC-TOE |
C C TIC-TAC-TOE |
COMMENT COMMENT TIC-TAC-TOE | ||||||||||||||||||||||||||||||||||||
| implicit typing? | no | yes | no | ||||||||||||||||||||||||||||||||||||
| implicit typing rules | (none) | I-N integer, otherwise real | (none) | ||||||||||||||||||||||||||||||||||||
| pointers? | no | no | no | ||||||||||||||||||||||||||||||||||||
| boolean variable declaration | (none) |
LOGICAL SWITCH LOGICAL*1 SWITCH LOGICAL*2 SWITCH LOGICAL*4 SWITCH | BOOLEAN SWITCH; | ||||||||||||||||||||||||||||||||||||
| integer variable declaration | (none) |
INTEGER COUNT INTEGER*2 COUNT INTEGER*4 COUNT |
INTEGER COUNT; | ||||||||||||||||||||||||||||||||||||
| real variable declaration | (none) |
REAL DISTANCE REAL*4 DISTANCE REAL*8 DISTANCE |
REAL DISTANCE; | ||||||||||||||||||||||||||||||||||||
| complex variable declaration | (none) |
COMPLEX ROOT1 COMPLEX*8 ROOT1 COMPLEX*16 ROOT1 | (none) | ||||||||||||||||||||||||||||||||||||
| array dimension specifier required? | yes (due to lack of type declarations) | no (due to implicit typing) | no (due to required typing) | ||||||||||||||||||||||||||||||||||||
| array bounds specifiers exist? | no | no | yes | ||||||||||||||||||||||||||||||||||||
| array bounds specifiers required? | no (don't exist) | no (don't exist) | yes | ||||||||||||||||||||||||||||||||||||
| default first subscript | 0 | 1 | (none--bounds required) | ||||||||||||||||||||||||||||||||||||
| lower bound / upper bound 1D dimension semantics | (UB) means index runs 0 through UB | (UB) means index runs 1 through UB | [LB:UB] means index runs LB through UB | ||||||||||||||||||||||||||||||||||||
| lower bound / upper bound 2D dimension semantics | (UB1, UB2) means indices run 0 through UB1, 0 through UB2 | (UB1, UB2) means indices run 1 through UB1, 1 through UB2 | [LB1:UB1, LB2:UB2] means indices run LB1 through UB1, LB2 through UB2 | ||||||||||||||||||||||||||||||||||||
| maximum number of dimensions | ? | 3-7 | ? | ||||||||||||||||||||||||||||||||||||
| array dimension declaration |
DIM P(10) DIM A(3, 5) DIM A(10), T(3, 5) |
DIMENSION POPULATION(10) DIMENSION A(3, 5) DIMENSION ARRAY(10), T(3, 5) | (none) | ||||||||||||||||||||||||||||||||||||
| array type declaration | (none--use DIM) |
REAL ARR1(10) REAL T(3, 5) INTEGER A(9) INTEGER Q(7) |
REAL ARRAY ARR1[1:10] REAL ARRAY T[1:3, 1:5] INTEGER ARRAY A[2:10] INTEGER ARRAY Q[-7:-1] | ||||||||||||||||||||||||||||||||||||
| string declaration | (none) | CHARACTER*64 filename | STRING ...? | ||||||||||||||||||||||||||||||||||||
| unconditional go to |
GOTO 30 . . . . |
GO TO 30 . . . . |
GOTO 30; GOTO SLEEP; GOTO JAIL; GOTO HELL; GO TO THERE; | ||||||||||||||||||||||||||||||||||||
| assigned go to |
. |
IF (J.EQ.1) ASSIGN 100 TO I IF (J.EQ.2) ASSIGN 200 TO I GOTO I 100 PRINT *, "100" GOTO 300 200 PRINT *, "200" 300 PRINT *, "END" . . . . . . . |
IF J=1 THEN I := 1; IF J=2 THEN I := 2; SWITCH J := 100, 200; GO TO J[I]; 100: 200:
SWITCH SEASON := SPRING, SUMMER, AUTUMN, WINTER; | ||||||||||||||||||||||||||||||||||||
| computed go to | . |
GO TO (101,102,103) K C DEFAULT GOES HERE ... GO TO 200 101 CONTINUE C K = 1 ... GO TO 200 102 CONTINUE C K = 2 ... GO TO 200 103 CONTINUE C K = 3 ... 200 CONTINUE | . | ||||||||||||||||||||||||||||||||||||
| labels | (none--use line numbers) |
30 . . . . |
30: SLEEP: JAIL: HELL: THERE: | ||||||||||||||||||||||||||||||||||||
| conditions need parentheses? |
no |
yes |
no | ||||||||||||||||||||||||||||||||||||
| if | (none) |
IF (X.LT.0) X = -X IF (A.GT.B) MAX = A | (none) | ||||||||||||||||||||||||||||||||||||
| if-then |
IF X < 10 THEN LET N = N + 1 END IF |
IF (X.LT.10) THEN N = N + 1 END IF |
IF X<10 THEN N := N+1; | ||||||||||||||||||||||||||||||||||||
| if-then-else |
IF X <= 10 THEN ... ELSE ... |
IF X <= 10 THEN ... ELSE ... END IF | . | ||||||||||||||||||||||||||||||||||||
| if-then- elseif-else |
IF X = 0 THEN ... ELSEIF X <= 10 THEN ... ELSEIF X <= 20 THEN ... ELSE ... END IF |
IF (X.EQ.0) THEN ... ELSE IF (X.LE.10) THEN ... ELSE IF (X.LE.20) THEN ... ELSE ... END IF |
IF X=0 THEN ... ELSE IF X<=10 THEN ... ELSE ...; ... IF X=0 THEN ... ELSE IF X<=10 THEN ... ELSE IF X<=20 THEN ...; | ||||||||||||||||||||||||||||||||||||
| for loops |
FOR I = 1 TO N ... NEXT I
FOR I = 1 TO 10 STEP 2 |
DO 100 I = 1, N ... 100
DO 100 I = 1, 10, 2 |
FOR I:=1 STEP 1 UNTIL N DO ... END
FOR I:=1 STEP 2 UNTIL 10 DO ... | ||||||||||||||||||||||||||||||||||||
| do loop |
DO ... LOOP UNTIL K = 32 |
DO WHILE (INPUT.NE.'N') ... END DO | . | ||||||||||||||||||||||||||||||||||||
| binary operators |
+ - * / ^ |
+ - * / ** |
+ - * / ^ | ||||||||||||||||||||||||||||||||||||
| logical operators |
AND OR NOT . . . |
.AND. .OR. .NOT. .EQV. (Fortran 77) .NEQV. (Fortran 77) . |
AND OR NOT EQV . IMP | ||||||||||||||||||||||||||||||||||||
| boolean values | . |
.TRUE. .FALSE. |
TRUE FALSE | ||||||||||||||||||||||||||||||||||||
| relational operators |
< <= = <> > >= |
.LT. .LE. .EQ. .NE. .GT. .GE. |
< <= = <> > >= | ||||||||||||||||||||||||||||||||||||
| scalar assignment |
LET R = 55 LET I = 5.5 LET A(1) = 0 LET A(K, K) = 1 LET E(I, J) = 4.5 |
RATE = 55 INTEREST = 5.5 A(1) = 0 A(K, K) = 1 EQUATION(I, J) = 4.5 |
RATE := 55; INTEREST := 5.5; A[1] := 0; A[K, K] := 1; EQUATION(I, J) := 4.5; | ||||||||||||||||||||||||||||||||||||
| automatic array assignment | MAT T = 0 |
. |
. | ||||||||||||||||||||||||||||||||||||
| string assignment |
LET B$ = "GOOD" |
. |
. | ||||||||||||||||||||||||||||||||||||
| single assignment | LET S2 = 1.4142136 | SQRT2 = 1.4142136 | SQRT2 := 1.4142136; | ||||||||||||||||||||||||||||||||||||
| multiple assignment | . | (none?) | ANG1 := ANG2 := 0; | ||||||||||||||||||||||||||||||||||||
| data |
DATA 4.48, 3.06 |
integer v(5) real B(2,2) data v/10,20,30,40,50/, B/1.0,-3.7,4.3,0.0/ | . | ||||||||||||||||||||||||||||||||||||
| I/O statements defined in language? | yes | yes | no | ||||||||||||||||||||||||||||||||||||
| input |
INPUT M |
READ(6,30) M 30 FORMAT(I1) |
inreal (0, guess); | ||||||||||||||||||||||||||||||||||||
| data read |
FOR I = 1 TO 2 READ X(I) | (none) | . | ||||||||||||||||||||||||||||||||||||
| output |
PRINT PRINT "HELLO!" PRINT F |
WRITE (*, *) ' HELLO!' | outstring (1, "Hello!"); | ||||||||||||||||||||||||||||||||||||
| spaced output | PRINT TAB(1 + 10 * (P MOD 8)) | . | . | ||||||||||||||||||||||||||||||||||||
| square root |
SQR(X) |
SQRT(X) DSQRT(X) CSQRT(X) |
SQRT(x) | ||||||||||||||||||||||||||||||||||||
| exponential function |
EXP(X) |
EXP(X) DEXP(X) CEXP(X) |
EXP(x) | ||||||||||||||||||||||||||||||||||||
| natural logarithm |
LOG(X) |
ALOG(X) DLOG(X) CLOG(X) |
LN(x) | ||||||||||||||||||||||||||||||||||||
| logarithm to base 10 |
LOG10(X) |
ALOG10(X) DLOG10(X) | (none) | ||||||||||||||||||||||||||||||||||||
| trigonometric functions |
SIN(X) COS(X) TAN(X) |
SIN(X), DSIN(X), CSIN(X) COS(X), DCOS(X), CCOS(X) TAN(X), DTAN(X) |
SIN(x) COS(x) TAN(x) | ||||||||||||||||||||||||||||||||||||
| inverse trigonometric functions |
. . ATN(X) |
ASIN(X), DASIN(X) ACOS(X), DACOS(X) ATAN(X), DATAN(X) |
. . ARCTAN(x) | ||||||||||||||||||||||||||||||||||||
| hyperbolic trigonometric functions | (none) |
SINH(X), DSINH(X) COSH(X), DCOSH(X) TANH(X), DTANH(X) | (none) | ||||||||||||||||||||||||||||||||||||
| truncation |
INT(X) |
AINT(X) ! Fortran 77 DINT(X) ! Fortran 77 | . | ||||||||||||||||||||||||||||||||||||
| round function |
ROUND(X) |
NINT(X) ! Fortran 77 | (none) | ||||||||||||||||||||||||||||||||||||
| absolute value | ABS(X) | ABS(X) | ABS() | ||||||||||||||||||||||||||||||||||||
| signum function | SGN(X) | SIGN(X) ! Fortran 95 | SIGN(x); | ||||||||||||||||||||||||||||||||||||
| random numbers |
RND | RAN(ISEED) ! Fortran 77 | RAND | ||||||||||||||||||||||||||||||||||||
| wait |
WAIT 120 WAIT 0.5 WAIT Wait_time WAIT Wait_time+60 WAIT | . | . | ||||||||||||||||||||||||||||||||||||
| integer to ASCII | PRINT CHR$(69) | . | . | ||||||||||||||||||||||||||||||||||||
| program statement exist? | no (in CDC 3300) | yes | no | ||||||||||||||||||||||||||||||||||||
| program statement required? | no (in CDC 3300) | no | no (does not exist) | ||||||||||||||||||||||||||||||||||||
| program statement | PROGRAM TTT | PROGRAM TTT | . | ||||||||||||||||||||||||||||||||||||
| simplest program |
END |
STOP END |
BEGIN END | ||||||||||||||||||||||||||||||||||||
| function definition |
DEF F(M, N) ... LET F = ... END DEF
AVG = SAVG(A,B,C) | ... END .
| function | definition
DEF FNA(X) = 2.1*X**3 - 4.06*X**2 + 11.9*X - 1.15 |
FUNCTION FAVG(I1,I2,I3) | INTEGER I1,I2,I3 FAVG = (I1+I2+I3)/3.0 RETURN END .
| function | call
LET W = FNA(1.25)
| .
| .
| procedure | definition
SUB initial(x,y) | ... END SUB .
|
REAL procedure average(A, n); | REAL array A; INTEGER n; begin ... average = ... end; procedure | call
CALL initial(x,y) |
CALL Pop (x) | .
| subroutine | call
GOSUB 100
|
CALL subroutine name (argument list) | CALL SAVG(A,B,C,AVG) .
| subroutine | definition
100 | ... RETURN
SUBROUTINE subroutine-name (arg1, arg2, ..., argn) | IMPLICIT NONE ... END SUBROUTINE subroutine-name
SUBROUTINE subroutine-name ()
SUBROUTINE subroutine-name
SUBROUTINE SAVG(I1,I2,I3,R1) .
| stop | required? no
| yes (until Fortran 77)
| no
| stop
|
STOP | .
STOP | STOP 52525
STOP | . end
|
END
|
END
|
END. | |