So I'm trying to complete this for an assignment. I need to print a pyramid of stars using 2 ways: the first with 4 cout statements; and the second with only 1 cout statement. However, on my second version, I can't manage to get the stars on different lines. Where do I put the endl so that it comes up with the same result as version 1?
thank you!!
But I would love to understand what is different from mine.
I noticed the editor places red marks after each line# in my version, but not in yours. The red marks are placed even before compiling.
You can use the new line character '\n' instead of endl. \n doesn't flush the output buffer like endl does so you can use that and then have an endl at the end of the statement.