program mixedassign

  implicit none
  real :: a = 3.9, b = 0.9, x = 1.3
  integer :: i, j, k

  i = a               ! assign a real to an integer 
  write(*,*) "i = ",i
  j = -b              ! assign a real to an integer 
  write(*,*) "j = ",j
  k = a - b           ! assign a real expression to an integer
  write(*,*) "k = ",k    
  
  a = i
  write(*,*) "a = ",a

!-- integer division: produces an integer result by truncation (toward zero)
  a = 1999/1000
  write(*,*) "a = ",a
  b = -1999/1000
  write(*,*) "b = ",b
  a = 1999.0/1000
  write(*,*) "a = ",a
  a = 1999/1000.
  write(*,*) "a = ",a    

!-- k/2 is computed as integer division, then is promoted to a real and added to x
  k = 5 
  x = x + k/2  
  write(*,*) "x = ",x    

end program mixedassign
