There is a "missing linefeed indicator" symbol (usually %) that is output if there is no trailing newline.
So the output of the program that outputs a newline looks like:
$ program
output
$
And output of the program without trailing newline: $ program
output%
$
There is an issue if the program is expected to output "%" at the end, of course.