+ 1

In c++ When we write ; and when de write <<endl;

I am a begginer in c++ Example 1 Cout>>"hello"; Example 2 Cout>>"hello">>endl; Please tell me when we write as the example 1 and when we write as the example 2 Or it is the same Thank you.

6th Dec 2019, 9:26 AM
iren yeger
iren yeger - avatar
5 Respostas
+ 2
example 2 are used when the next output needs tobe in the new line. example 1 used when the next output need to be in the same line
6th Dec 2019, 9:30 AM
Taste
Taste - avatar
+ 3
The deference between Example1 cout<<"hello; And Example2 cout<<"hello"<<endl; Is in the 1st ex you are saying to the program write hello and stop But in the other ex you are saying to the program write hello and return to a new line and stop endl = "\n" Its the same the only deference between them is : endl used outside the " " cout<<"hello"<<endl; "\n" used inside the " " Cout<<"hello\n"; More examples: Ex1 cout<<"hello "<<"world"; Output hello world Ex2 Cout<<"hello"<<endl<<"world"; Output hello World Ex3 Cout<<"hello"<<"world"<<endl<<"i am code"; Output Hello world I am coder Hope this will help you 😊😁😀 And if you have any other questions i am here bro
7th Dec 2019, 9:16 PM
$p@rK
$p@rK - avatar
+ 1
~ swim ~ Thank you i just missed it
6th Dec 2019, 10:06 AM
iren yeger
iren yeger - avatar
0
Thank you Taste
6th Dec 2019, 9:35 AM
iren yeger
iren yeger - avatar