program suffices integer, parameter :: n = 4 character(len=2), dimension(0:n) :: & suffix = (/ 'th', 'st', 'nd', 'rd', 'th' /) index(m) = min(max(0, modulo(abs(k), 10)), 4) do k = -100, 100 write(*,'(i4, a)') k, suffix(index(k)) end do end program suffices