+ 2

What is the difference between cout<<1+2; and cout<<1+2<<endl;

29th Dec 2016, 6:27 AM
School Dog
5 Answers
+ 3
endl moves down to a new line before printing the next text
29th Dec 2016, 6:41 AM
Felipe Matheus Laurindo
Felipe Matheus Laurindo - avatar
+ 3
the second thing will make a new line, sience endl mens end line. for example lets asume the first line of the code above as A and the secod as B, if you write A then B the result will be 33 but if you write B then A the result will be 3 3
29th Dec 2016, 6:45 AM
Muhammad Sultoni
Muhammad Sultoni - avatar
+ 2
std::endl flushes the stream so everything gets printed if you dont use it the stream gets flushed when his tie (in this case std::cin) is used or the programm ends
29th Dec 2016, 7:35 PM
Roman GrÀf
Roman GrÀf - avatar
+ 1
endl instruction moves outputes to the next line. you'll see that good writing two codes: first cout << 1+2 << 3+4; second cout << 1+2 << endl << 3+4;
29th Dec 2016, 6:35 AM
Slawomir Maciejewski
+ 1
Thank you!!!
29th Dec 2016, 10:40 PM
School Dog