# LOGICAL Input

### Problem Statement

Suppose we have an input organized as follows. The first line gives the number of lines, followed by that number of input lines. Each line is divided into two parts with 10 positions each. Each part contains a LOGICAL input.
1    1    2    2
....5....0....5....0....5
4
T         .TR
.TRUE.        Franco
February   Truman
.FALSE.  fake
Write a Fortran program that reads in the above input, and prints the input values and the results of .OR., .AND., .NEQV. and .EQV. in the following form:
1    1    2    2    3    3    4    4
....5....0....5....0....5....0....5....0....5
Truth Table
-----------

P      Q    P | Q  P & Q  P ^ Q  P = Q
-----  -----  -----  -----  -----  -----
T      T      T      T      F      T
T      F      T      F      T      F
F      T      T      F      T      F
F      F      F      F      F      T
We use |, &, ^ and = to indicate .OR., .AND., .NEQV. and .EQV., respectively. Note that the first position is always for printer control.

### Solution

PROGRAM  Logical_Input
IMPLICIT  NONE
LOGICAL           :: P, Q
INTEGER           :: i, Number

WRITE(*,"(A, A)")  " ", "  Truth Table"
WRITE(*,"(A, A)")  " ", "  -----------"
WRITE(*,*)
WRITE(*,"(A,A)")   " ", "    P      Q    P | Q  P & Q  P ^ Q  P = Q"
WRITE(*,"(A,6A)")  " ", ("  -----", i = 1, 6)
DO i = 1, Number
WRITE(*,"(A, 6L7)")  " ", P, Q, &
P .OR. Q, P .AND. Q, P .NEQV. Q, P .EQV. Q
END DO
END PROGRAM  Logical_Input

### Program Input and Output

The output of the program is:
1    1    2    2    3    3    4    4
....5....0....5....0....5....0....5....0....5
Truth Table
-----------

P      Q    P | Q  P & Q  P ^ Q  P = Q
-----  -----  -----  -----  -----  -----
T      T      T      T      F      T
T      F      T      F      T      F
F      T      T      F      T      F
F      F      F      F      F      T

### Discussion

• Since each input line has two LOGICAL values each of which occupies 10 positions, the format is simply (2L10).
• For the output, we use six positions for each output value. Since there are two spaces between two adjacent columns, we use 6L7 to print the six LOGICAL values.