Increment Operator

What Is an Increment in Computing?

Learn what an increment means in computing, where counters and loop variables use one, and how C++ writes an increment using the ++ operator.

On this page
  1. The short answer
  2. Where increments show up
  3. Increment and decrement
  4. Increments in C++
  5. Quick summary

The short answer

In computing, an increment is a step up in a value, usually by one. Adding 1 to a counter is an increment. Its opposite is a decrement, which steps a value down, usually by one.

Where increments show up

Increments appear in many everyday programming tasks:

  • Counters track how often something happens, such as clicks, errors, or items processed.
  • Loop variables move through a sequence one step at a time.
  • Indexes point to the next position in a list or array.
  • Program counters in a processor usually move forward after each instruction.
  • Identifiers are sometimes assigned by taking the last number and increasing it by one.
  • Version numbers can go up by one for each small update, depending on the versioning scheme.

Increment and decrement

An increment raises a value, and a decrement lowers it. Both usually work in steps of one. In a loop, the loop variable may go up with each pass or down with each pass, depending on how the loop is written.

Increments in C++

In C++, you increase a variable with the c increment operator, written ++. Here is a small example:

#include <iostream>

int main() {
    int visits = 0;
    visits++;  // one more visit
    visits++;  // two visits
    std::cout << visits << "\n";  // prints 2
    return 0;
}

The ++ symbol can go before or after a variable. Both forms add one, but they give back different values when used inside a larger expression.

Quick summary

  • An increment raises a value, usually by one.
  • Counters, loops, indexes, identifiers, and version numbers all rely on increments.
  • In C++, ++ increments a variable.

The complete guide to increment operator

The Increment Operator in C++
Read the guide

Keep exploring

Guides from other topics

All topics →

Encapsulation in C++

Encapsulation in C++: how private data, public member functions and access control keep objects valid, with a clear class example and common mistakes.

Encapsulation 4 min read

Static Classes in C++

C++ has no static class keyword. Here is how static members, utility classes and namespaces cover the same job, with short code examples for each.

Static Classes 5 min read

Concurrency in C++

Learn concurrency in C++ with std::thread, mutexes, atomics and futures. Covers data races, deadlocks and common mistakes, with short compilable examples.

Concurrency 5 min read