You are on page 1of 1

Learn C++

Hello World Write, compile, and execute your first C++ program

hello.cpp
1 #include <iostream>
This is a classic first step that all new
2
programmers take — they greet the
3 int main() { world through the terminal!
4

5 std::cout << "Hello World!\n"; ← This is a statment that outputs


the phrase Hello Word!
6

7 return 0;

9 }

Terminal:
Hello World!
This would appear in the black box!

Compile & Execute Basic terminal commands

Using default executable file name.


$ g++ hello.cpp ← Compile
$ ./a.out ← Execute

Renaming the executable file.


$ g++ hello.cpp -o hello ← Compile
$ ./hello ← Execute

Notes:

You might also like