Skip to content
CP4CPP logo
CP4CPP/EDU
App settings
Installation and offline settings

Preparing update checks...

Workspaces

12

Reading record

Reading statistics
Reading progress
-
Words
-
Reading estimate
-
Preset chosen
-
Code blocks
-
Images and diagrams
-
Preferences and widgets

    Shared across workspaces

    Heading markersPercentage markers

    Lesson 1 - Your First C++ Program

    • None. This is the first lesson in the beginner path.
    • A working C++ setup that can build and run a single source file.
    • The stages that turn C++ source text into a running program.
    • What a complete, minimal C++ program looks like.
    • How to make a program print one exact line of text.

    C++ is a compiled language. The text you write is not what the machine runs. Your text passes through a fixed sequence of stages first.

    source
    |
    | compile
    v
    object code
    |
    | link
    v
    executable
    |
    | run
    v
    output

    Read the stages like this:

    • source is the C++ text you write and save in a file
    • compile translates one source file into machine instructions
    • object code is that translated result, which is not runnable on its own
    • link joins your object code with the standard library code it depends on
    • executable is the finished program file the system can start
    • run starts the executable, which then produces output

    Two ideas from this sequence matter for the rest of the path:

    • A mistake in your text is usually reported at the compile stage, before anything runs
    • Nothing you write produces output until the run stage is reached

    This is a complete program. Nothing is missing from it.

    #include <iostream>
    int main() {
    std::cout << "Hello, CP4CPP!\n";
    return 0;
    }

    Output:

    Hello, CP4CPP!

    Each part has a job:

    • #include <iostream> brings in the standard input and output declarations. Without it, std::cout is not declared.
    • int main() declares the function where the program starts. Every program in this path has exactly one main.
    • { and } mark the start and end of the body of main.
    • std::cout is the standard output stream. The std:: prefix says the name comes from the standard library.
    • << sends the value on its right into the stream on its left.
    • "Hello, CP4CPP!\n" is the text to print. The \n is one newline character, so the output ends with a line break.
    • return 0; ends main and reports success to the system.

    Write a complete program that prints exactly one line:

    I compiled my first C++ program.

    Start from the worked example and change only the text between the quotation marks. Keep #include <iostream>, int main(), the \n, and return 0; exactly as they are.

    Expected output:
    I compiled my first C++ program.

    This program reads no input, so there is nothing to type when it runs.

    Check these before moving on:

    • The line matches the expected output exactly, including the final period
    • There is no extra text before or after the line
    • The program reached the run stage, which means compiling and linking both succeeded

    You can now produce fixed output. The next lesson keeps this program shape and adds input, named variables, and arithmetic, so the output depends on what the program is given.

    Reader layout

    Col / Left

    Left column

    LEFT
    Width
    Rail
    ...
    CENTER
    Width
    Rail
    ...
    RIGHT
    Width
    Rail
    ...
    TOP
    NAV
    MID
    BOT

    Theme settings

    Preset 0 · Default · Locked

    Advanced colors · OKLCH

    Choose preset 1-9 to edit. Changes save on this device. Each color inherits in this order: cell → row → column → app → base theme.

    Editing All

    Selected scope

    Chroma 0 is neutral gray. Displayable colors depend on your screen; the browser maps colors outside its gamut. Grayscale also affects images and charts.

    Progress appearance

    Loading controls…

    Forest0.88 kB
    Slate0.88 kB

    Font settings

    Preset 0 · Default · Locked

    Font typography
    Advanced typography

    Auto uses the selected spacing mode. Variants and available weights depend on the font. The browser may synthesize missing weights or styles.

    a b c d e f g h i j k l m n o p q r s t u v w x y z

    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    0 1 2 3 4 5 6 7 8 9

    ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~

    abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

    Iosevka Extended10.76 MB
    Inter297.90 kB
    Source Sans 3197.90 kB
    Lora138.11 kB
    Source Serif 4216.02 kB
    JetBrains Mono130.64 kB
    Fira Code53.67 kB

    Keybinds

    Choose a binding, press up to 4 keys together, then release to save. Modifiers count as keys. Esc clears the selected binding. Unsupported keys show Unknown.

    Reader

    Forbidden key combinations

    Windows / Linux reference. These combinations are reserved by this app to avoid browser, system and editing conflicts. Some are intercepted before a page can receive them. Browser extensions and other operating systems may reserve additional keys.

    Fixed navigation: Ctrl + K opens Search. Alt + F6-F9 selects a row; Alt + F10-F12 selects a column. Combine both to select a cell. While selected, F1 captures a screenshot and F2 downloads PNG. Esc cancels dialogs and navigation when a binding is not being recorded.