You might want to use endl if you plan to write portable code, since it becomes \n on *nix, \r on mac os and \r\n on windows if i'm not mistaken.
STUDIOny wrote:but, where would I include the \n in the following code?
- Code: Select all
cout << "First we will add: " << tempInt1 << " + " << tempInt2 << " = " << total1;
Wherever you want it (and would have put the \n):
- Code: Select all
cout << "First we will add: " << tempInt1 << " + " << tempInt2 << " = " << total1 << endl;
to make it "First we will add: 1 + 2 = 3<newline here>
".
Or probably
- Code: Select all
cout << "First we will add: " << endl << tempInt1 << " + " << tempInt2 << " = " << total1 << endl;
to make it "First we will add: <newline here>
1 + 2 = 3<newline here>
".