Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

hello
world
c++
cout

How to write "Hello World" in C++

Educative Answers Team
svg viewer

The first step to learning any programming language is to learn how to give input to a program or display its output. In C++, the output is shown on the console using the cout output-stream variable and the << operator.

cout can be used in the following two ways:

  1. Using the scope resolution operator to specify the std namespace in which the cout object resides.

  2. Specifying the std namespace with the using keyword and then using cout.

The iostream header file must be included for interaction with the console.

Code

#include <iostream>

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

RELATED TAGS

hello
world
c++
cout
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring