+ 5
Correct use of \n
The questions use new line like " cout << "Hello \n World"; Not sure if that would work on the computer. Shouldnt it be " cout << "Hello " << \n << "world!";
9 Respuestas
+ 2
It will definitely work the correct way is \n has to be inside " " doesn't matter if it is in the middle of the sentence like
cout<<"Hell\no world";
will print
Hell
o world
+ 6
The correct of \n is following
cout << "Hello \n World";
In line
cout << "Hello " << \n << "world!";
The problem is you have to pass "\n" with the double quotes.
This line will work if you will put \n inside quotes. Like this👇
cout << "Hello " << "\n "<< "world!";
+ 6
endl is another way to add a new line.
+ 3
These are known as EscapeSequences.
•\t: It is used forHorizontal tab.
•\n: It is used forNew line.
•\b: It is used forBackspace.
Hope it was helpful..!
+ 2
Yes it's best Sonic
+ 2
both will work fine
just remember to use single quotes while using escape sequence
+ 1
Using it inside the string (double quotes) is the correct way. There are other characters that are enterpretted too like this, all starting with the “\” like “\t” for a tab. The “\” is used to escape the string too for characters that would normally cause problems, like double quotes.
cout << “He said \”Hello world\” and others knew he was a programmer” << endl;
This line prints quotes around “Hello world” without breaking the string.
+ 1
Both are correct 🙂
0
Hay