There's nothing inherently dangerous about having a function output something. It's certainly not good that you don't flush the output stream, as you then can't know when the output will actually appear.
When you pass something to cout as above, it may or may not actually appear on screen straight away. It may wait a while. You can guarantee it will appear immediately by flushing the stream.
No. I don't mean that at all. I'm not talking about that at all.
I'm saying that when you send something to cout, you are not actually sending it to screen. You are sending it to a buffer somewhere, and it will appear on screen when something else decides. Might be straight away. Might be in the future. If you want it to come out on screen now, you must do something called flushing.
Here is one way you can flush:
cout << endl;
Here is another way you can flush: cout.flush();
This has nothing at all to do with your choice of endl and \n