Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. C++ Course

Lesson 23 of 45 · C++

Lesson 3: Hello World and Basic Syntax

Duration: 6 min

Hello World and Basic Syntax\n\nIn this lesson you will explore the minimal set of C++ constructs needed to write a runnable program. The compiler processes three distinct phases:\n1. Preprocessing – handling #include, #define and other directives.\n2. Compilation – translating the cleaned source into assembly.\n3. Linking – combining object files and libraries into an executable.\n\n---\n\n## The canonical "Hello, World!" program\ncpp\n#include <iostream>\n\nint main() {\n std::cout << \"Hello, World!\" << std::endl;\n return 0;\n}\n\n\nKey observations:\n- The #include directive pulls in the iostream header.\n- int main() is the entry point.\n- std::cout writes to the standard output stream.\n- std::endl inserts a newline and flushes the buffer.\n\n> Tip: Try compiling with g++ -std=c++20 -Wall -Wextra hello.cpp -o hello to see warnings that help you write safer code.\n\n---\n\n

Note

Understanding the compilation pipeline will make debugging later much easier.

Previous: Lesson 29: List ContainerNext: Lesson 30: Deque Container