Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    C++C++

    C++ fundamentals

    • Your first C++ program
    • Variables and types
    • Operators and input
    • Conditions: if and switch
    • Loops

    Functions and collections

    • Functions
    • References: by value or by reference?
    • Strings and arrays
    • std::vector
    • map, set and unordered_map

    Memory and pointers

    • Pointers
    • Stack, heap, new and delete
    • Smart pointers and RAII

    Classes and OOP

    • struct and class
    • Constructors and destructors
    • Inheritance and virtual functions
    • Templates

    The STL and professional C++

    • Algorithms and lambdas
    • Exceptions
    • Recursion
    • Project: a grade book
    C++

    C++ fundamentals · Lesson 1 of 21

    Your first C++ program

    What a compiled language is, the parts of a program, and cout.

    8 minutes2 games

    C++ is a very fast language close to the hardware. Game engines (Unreal), browsers (Chrome), databases and embedded devices are written in it, and it's the favourite language of programming contests.

    The big difference from JavaScript and Python is that it's compiled: before the program runs, the compiler translates all the code into a machine-code file. If there's a mistake in the code, the program won't run at all.

    main.cpp (your code)

    the compiler (g++)

    an executable in machine code

    run

    When you press Run here, the server does all of these steps.

    C++
    #include <iostream>
    
    int main() {
        std::cout << "Hello, SeaCode!\n";
        std::cout << "2 + 3 = " << 2 + 3 << "\n";
        return 0;
    }

    Line by line:

    • #include <iostream> brings in the input/output library.
    • int main() is where the program starts; it must exist.
    • std::cout << … prints, and << chains pieces together.
    • "\n" is a new line, and ; ends each statement.
    • return 0; means "finished without problems".

    You'll often see using namespace std; at the top so you can write cout instead of std::cout. Fine in small exercises, but in large projects prefer std:: so names don't clash.

    Important

    C++ is case-sensitive (Main is not main) and every statement needs ;. Any compile error stops the whole program, so read the compiler's message from its first line: it names the line number and the problem.

    Spot the bug

    This program won't compile. Which line?

    Interview question

    What's the difference between compiled and interpreted languages?

    Exercise

    Write a program that prints exactly two lines: I am learning C++ 10 * 12 = 120 (compute the 120 in code, don't type it).

    Expected output:
    I am learning C++
    10 * 12 = 120
    C++
    #include <iostream>
    
    int main() {
        
        return 0;
    }

    Learn more from

    • learncpp: Introduction to C++learncpp.com
    • learncpp: Statements and the structure of a programlearncpp.com
    • cppreference: main functionen.cppreference.com

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    NextVariables and types
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.