Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Displaying the text in C++

How to print text in C++?

There is a simple way of printing text in C++. You can use the 'cout' object along with the insertion operator, '>>'. You need to write all the basic lines of C++ code first and inside a curly bracket'{}', write 'cout>>' and then write the text in double quotes (""). Also remember to add the semi-colon at the end of the line.
For example-

#include 
using namespace std;
int main()
{
cout

Try It Out Here

Adding a break between two pieces of text

You can add a break between lines by adding '\n' after every piece of text that has to be printed. For example-

#include 
using namespace std;
int main()
{
cout

Try It Out Here

Similarly, the number of lines can be increased by adding '\n' characters at the end of the lines.

Adding a horizontal tag

You can add a horizontal tag by writing '\t' at the end of the line like the '\n'. For example;

#include 
using namespace std;
int main()
{
cout

Try It Out Here

Putting double quotes around a piece of text

You can put double quotes by adding '\"' at the start and the end of the piece of text. For example-

#include 
using namespace std;
int main()
{
cout

Try It Out Here

That is all for this post. Follow this blog to get more info on coding.

Regards,
Aarav Iyer

References;

(1) https://www.w3schools.com/cpp/cpp_output.asp



This post first appeared on Code Streak, please read the originial post: here

Share the post

Displaying the text in C++

×

Subscribe to Code Streak

Get updates delivered right to your inbox!

Thank you for your subscription

×