program main implicit none character(100) :: S integer :: i, code, length read *, S length = len_trim(S) do i = 1, length code = iachar(S(i:i)) if (code >= iachar('A') .and. code <= iachar('Z')) then S(i:i) = achar(code + 32) else S(i:i) = achar(code - 32) end if end do print *, trim(S) end program main