Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 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