Computers in Engineering WWW Site - Example 3.4

# Example 3.4

#### FORTRAN Version

```!
PROGRAM P34
!
!
!     Reading and testing LOGICAL variables
!
!
IMPLICIT NONE
LOGICAL :: SINGLE
CHARACTER (LEN=15) :: NAME
INTEGER :: I,J,MARRGS
!
PRINT *, 'This is Program >> P34  - Testing with LOGICAL data'
!
!
!
L1:   DO J=1,I
IF(NAME  ==  'DONE')EXIT  ! Leave the DO loop
IF(SINGLE)THEN
PRINT * ,NAME,'IS SINGLE'
ELSE
PRINT * ,NAME,'WAS MARRIED',  &
MARRGS,'TIMES'          ! A continued line
END IF
END DO L1   ! The EXIT brings control to next statement
STOP
END PROGRAM P34
```
DATA:
```3
'Jane Simpson'       T
'Mary Morrison'      F
3
'DONE'               T
```
OUTPUT:
```
+--------------------------------------------------+
|     32-bit Power for Lahey Computer Systems      |
|   Phar Lap's 386|DOS-Extender(tm) Version 7.0    |
|  Copyright (C) 1986-94 Phar Lap Software, Inc.   |
|           Available Memory = 14880 Kb            |
+--------------------------------------------------+

This is Program >> P34  - Testing with LOGICAL data
Jane Simpson   IS SINGLE
Mary Morrison  WAS MARRIED           3TIMES
```

#### Pascal Version

```{\$G256}
{\$P512}
{\$D+}
PROGRAM p34 (input, output);
VAR
single_tmp : 0..1;
marriages : INTEGER;
single : BOOLEAN;
name : STRING[15];
BEGIN
WHILE (name <> 'done') DO
BEGIN
IF ( single_tmp=1 ) THEN single := TRUE;
IF ( single_tmp=0 ) THEN single := FALSE;
IF single THEN
writeln ( name, 'is single')
ELSE
BEGIN
writeln ( name, 'was married ' , marriages, ' times')
END; { end else }
```Jane Simpson       1