PROGRAM Binary_Adder
!-----------------------------------------------



IMPLICIT NONE
INTEGER :: Input1, Input2, A_1, A_2, B_1, B_2, Sum1, Sum3, Carry
LOGICAL :: In_A1, In_A2, In_B1, In_B2, S1, TempS2, S3, CarryL

!Get the Binary numbers
WRITE (*,*) "Enter the first binary number: "
READ (*,*) Input1
WRITE (*,*) "Enter the second binary number: "
READ (*,*) Input2



A_1 = MOD(Input1,10)
A_2 = Input1/10

B_1 = MOD(Input2,10)
B_2 = Input2/10


IF(A_1 == 1) THEN
In_A1 = .TRUE.
ELSE
In_A1 = .FALSE.
END IF

IF(A_2 == 1) THEN
In_A2 = .TRUE.
ELSE
In_A2 = .FALSE.
END IF

IF(B_1 == 1) THEN
In_B1 = .TRUE.
ELSE
In_B1 = .FALSE.
END IF

IF(B_2 == 1) THEN
In_B2 = .TRUE.
ELSE
In_B2 = .FALSE.
END IF


S1 = ((In_A1 .OR. In_B1) .AND. (.NOT. (In_B1 .AND. In_A1)))

TempS2 = ((In_A2 .OR. In_B2) .AND. (.NOT. (In_B2 .AND. In_A2)))

S3 = (TempS2 .OR. (In_A1 .AND. In_B1)) .AND. (.NOT.(TempS2 .AND. (In_A1 .AND. In_B1) ))

CarryL = ((In_A2 .AND. In_B2) .OR. (TempS2 .AND. (In_A1 .AND. In_B1)))




IF(S1) THEN
Sum1 = 1
ELSE
Sum1 = 0
END IF

IF(S3) THEN
Sum3 = 1
ELSE
Sum3 = 0
END IF

IF(CarryL) THEN
Carry = 1
ELSE
Carry = 0
END IF



WRITE(*,*) "The sum is: ", Carry,Sum3,Sum1







STOP
END PROGRAM Binary_Adder