Why do we use the angular brackets? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why do we use the angular brackets?

The 'printing a text' tutorial gives the example of printing a text in the following manner: int main() { cout << "This " << "is " << "awesome!"; return 0; } Why are the angular brackets used in between the words "This", "is" and "awesome"? I tried removing the angular brackets in 'Try it Yourself' and there was no effect on the final product.

7th Sep 2018, 1:34 PM
K. Wong
1 Answer
+ 4
You can either print three separate strings or one longer string, there will be no diferrence. You don't really have to put << between the words in your example. It is useful when you want to put a variable between text: int a=10; cout << "The variable has value "<<a<<".\n";
7th Sep 2018, 1:41 PM
michal