C++ Displaying Text on Screen

In this article, we are going to learn how to display text on the screen using C++. I am using a Visual Studio 2017 Community Edition. You can download it for free on this link Visual Studio 2017 Community Edition.

After installing,
Step 1: Open Visual Studio 2017 Community Edition
Step 2: Click File -> New -> Project
Step 3: Select Visual C++
Step 4: Under Visual C++, Select Windows Desktop
Step 5: Select Windows Console Application
Step 6: Write the name of the Project and click OK.

Capture

After clicking OK, this will be showing on your screen with the following codes.

Capture1

Press Control + F5 to see the output that we coded in Visual Studio

Capture2

Example: We want to write a program displaying “Hello” on the first line, and “World” on the second line.

To do that, change your code into

#include "pch.h"
#include 

int main()
{
    std::cout << "Hello" << std::endl;
	std::cout << "World!";
}

Press Control + F5. Below is the output.Capture3It breaks the line because of the std::endl;
std::endl;     —means the next cout should be on the next line
cout     —is what are you going to display in the screen

Testing: Without coding std::end; after “Hello”.

#include "pch.h"
#include 

int main()
{
    std::cout << "Hello ";
std::cout << "World!";
}

Press Control + F5. And below is the output.

Capture4

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s