+ 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 Respostas
+ 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