c hello world how to

The Hello World program is tradition when learning a programming language. Here’s how to do it in C++.

The code:

#include

int main()
{
std::cout << "Hello World!"; } The code breakdown: Line 1: #include

This, in simple terms, tells the program to use pre-constructed code in C++ needed when printing onto the screen.

Line 2: int main()

Defines the “main” function. All C++ programs start with a main function.

Line 3: std::cout << "Hello World!"; First thing on the line is std, which stands for Standard Character Output. This defines the device to output to, which is usually the screen. The << characters indicate that the string "Hello World!" is inputted into std::cout. The semicolon (;) is used similarly to an english period, marking the end of a statement.

Publisher: adam

Share this post