zrhans

logicalOp2.f90

Jan 10th, 2021 (edited)
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program logicalOp2
  2.  
  3. ! this program checks logical operators
  4. implicit none  
  5.  
  6.    ! variable declaration
  7.    logical :: a, b
  8.  
  9.    ! assigning values
  10.    a = .true.  
  11.    b = .false.
  12.  
  13.    if (a .and. b) then
  14.       print *, "Line 1 - Condition is true"
  15.    else
  16.       print *, "Line 1 - Condition is false"
  17.    end if
  18.  
  19.    if (a .or. b) then
  20.       print *, "Line 2 - Condition is true"
  21.    else
  22.       print *, "Line 2 - Condition is false"
  23.    end if
  24.  
  25.    ! changing values
  26.    a = .false.  
  27.    b = .true.
  28.  
  29.    if (.not.(a .and. b)) then
  30.       print *, "Line 3 - Condition is true"
  31.    else
  32.       print *, "Line 3 - Condition is false"
  33.    end if
  34.  
  35.    if (b .neqv. a) then
  36.       print *, "Line 4 - Condition is true"
  37.    else
  38.       print *, "Line 4 - Condition is false"
  39.    end if
  40.  
  41.    if (b .eqv. a) then
  42.       print *, "Line 5 - Condition is true"
  43.    else
  44.       print *, "Line 5 - Condition is false"
  45.    end if
  46.  
  47. end program logicalOp2
  48.  
Add Comment
Please, Sign In to add comment