Lesson 3 of 45
C++Lesson 3: Hello World and Basic Syntax
6 min
Course progress7%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 3 of 45
C++6 min
Keep these ideas in mind as you work through the lesson.
In this lesson you will explore the minimal set of C++ constructs needed to write a runnable program. The compiler processes three distinct phases:
#include, #define and other directives.#include <iostream>
int main() {
std::cout << \"Hello, World!\" << std::endl;
return 0;
}
Key observations:
#include directive pulls in the iostream header.int main() is the entry point.std::cout writes to the standard output stream.std::endl inserts a newline and flushes the buffer.Tip: Try compiling with
g++ -std=c++20 -Wall -Wextra hello.cpp -o helloto see warnings that help you write safer code.