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
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Lesson 3: Hello World and Basic Syntax | C++ Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. C++ Course

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.

4 points
  • Include directives and namespaces
  • Main function signature
  • Using std::cout
  • Compilation and execution steps

Hello World and Basic Syntax

In this lesson you will explore the minimal set of C++ constructs needed to write a runnable program. The compiler processes three distinct phases:

  1. Preprocessing – handling #include, #define and other directives.
  2. Compilation – translating the cleaned source into assembly.
  3. Linking – combining object files and libraries into an executable.

The canonical "Hello, World!" program

#include <iostream>

int main() {
    std::cout << \"Hello, World!\" << std::endl;
    return 0;
}

Key observations:

  • The #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 hello to see warnings that help you write safer code.


Note

Understanding the compilation pipeline will make debugging later much easier.
Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from C++ CourseBrowse activities
Previous lessonLesson 2: Setting Up Development EnvironmentContinue to lesson 4Lesson 4: Variables and Data TypesBack to C++ Course curriculum