They are both correct, but endl is redundant in this case since cout.flush() is called two lines below, when main() ends. (it is also called on any input from cin, and at other times).
As for whether it matters, it does not usually mater for screen output (endl is only a little slower), but when writing to a file, unnecessary flushing makes the output much slower.
They are both correct, and in a sense it doesn't really matter. The main issue is, of course, the usingnamespace std; bit.
What this does is takes all of the contents of the std namespace and "dumps" it into the global namespace; for simple programs this doesn't really matter but if, say, you were writing a header for your library you wouldn't ever want to do that. If you did, anyone using your header would immediately have the std namespace imported into the global one, possibly giving them unexpected results.