printf uses buffered I/O .
data is stored in internal buffers, waiting for the buffer to fill completely ,before data is flushed to console or files.
In case of this code ,the data doesnt compeletly fill the printf buffer &printf is waiting indefinitely for the buffer to fill.
Adding a new line char (\n) will force the buffer to flush(write) on console.