Display output messages using "cout"

In the video the default code block is:
2

My code is:

Fundamentally the output given is the same. Is there anything different execution wise or something like that?

Not really. Performance differences (if any) wlil be insignificant. Probably a matter of style. I can see where it would make sense to break down the statements in a tutorial, either for readability, or clarity, or due to screen real-estate. Chances are, when this code is compiled, it is turned into the exact same machine code regardless of your approach.

Since the compiler ignores extra whitespaces, the original code could have excluded the semicolon on the first line, and the cout on the second line. Then again, not the most readable code, particularly for a tutorial.

There are other items that can be considered when it comes to implementation and performance with cout, as endl vs "\n". But then again that is not what you asked ;).

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms