Increment and decrement operators

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages feature two versions (pre- and post-) of each operator with slightly different semantics. In languages syntactically derived from B (including C and its various derivatives), the increment operator is written as ++ and the decrement operator is written as --. Several other languages use inc(x) and dec(x) functions. In languages that support both versions of the operators:

Comment
enIncrement and decrement operators are unary operators that add or subtract one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages feature two versions (pre- and post-) of each operator with slightly different semantics. In languages syntactically derived from B (including C and its various derivatives), the increment operator is written as ++ and the decrement operator is written as --. Several other languages use inc(x) and dec(x) functions. In languages that support both versions of the operators:
Has abstract
enIncrement and decrement operators are unary operators that add or subtract one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages feature two versions (pre- and post-) of each operator with slightly different semantics. In languages syntactically derived from B (including C and its various derivatives), the increment operator is written as ++ and the decrement operator is written as --. Several other languages use inc(x) and dec(x) functions. The increment operator increases, and the decrement operator decreases, the value of its operand by 1. The operand must have an arithmetic or pointer data type, and must refer to a modifiable data object. Pointers values are increased (or decreased) by an amount that makes them point to the next (or previous) element adjacent in memory. In languages that support both versions of the operators: * The pre-increment and pre-decrement operators increment (or decrement) their operand by 1, and the value of the expression is the resulting incremented (or decremented) value. * The post-increment and post-decrement operators increase (or decrease) the value of their operand by 1, but the value of the expression is the operand's value prior to the increment (or decrement) operation. In languages where increment/decrement is not an expression (e.g., Go), only one version is needed (in the case of Go, post operators only). Since the increment/decrement operator modifies its operand, use of such an operand more than once within the same expression can produce undefined results. For example, in expressions such as x - ++x, it is not clear in what sequence the subtraction and increment operations should be performed. Such expressions generally invoke undefined behavior, and should be avoided. In languages with typed pointers like C,the increment operator steps the pointer to the next item of that type -- increasing the value of the pointer by the size of that type.When a pointer (of the right type) points to any item in an array, incrementing (or decrementing) makes the pointer point to the "next" (or "previous") item of that array.When a pointer has a type of pointer-to-integer,incrementing that pointer makes it point to the next integer (typically increasing it by 4 bytes).When a pointer has a type pointer-to-employee, incrementing that pointer makes it point to the next "employee" -- if the size of the employee structure is 106 bytes, incrementing that pointer increases it by 106 bytes.
Hypernym
Operators
Is primary topic of
Increment and decrement operators
Label
enIncrement and decrement operators
Link from a Wikipage to another Wikipage
ABAP
Array data structure
Augmented assignment
AWK
B (programming language)
Bash (Unix shell)
C (programming language)
C++
Category:Operators (programming)
Category:Unary operations
ColdFusion Markup Language
C Sharp (programming language)
D (programming language)
Data object
Data type
Delphi (programming language)
GNU Octave
Go (programming language)
GP
Imperative programming
Java (programming language)
JavaScript
Ken Thompson
Modula-2
Oberon (programming language)
Objective-C
Operand
Operator (programming)
Pascal (programming language)
PDP-11
PDP-7
Perl
PHP
Pointer (computer programming)
PowerShell
Programming language
Python (programming language)
Rust (programming language)
Successor function
Swift (programming language)
Unary operator
Undefined behavior
Vala (programming language)
Wolfram Language
SameAs
++
AmAo
Artma miqdarı
Increment
Incrémentation
Inkrementacja
Inkrementel
Inkrement og dekrement
Inkrement und Dekrement
Kremento
m.0g56 mx
Operadores de incremento y decremento
Q11067259
Інкрэмент
Инкремент
Инкремент
Инкремент және декремент операторлары
Оператори інкременту та декременту
مشغل الزيادة والنقص
インクリメント
增值和减值操作符
증감 연산자
Subject
Category:Operators (programming)
Category:Unary operations
WasDerivedFrom
Increment and decrement operators?oldid=1124772344&ns=0
WikiPageLength
10798
Wikipage page ID
25848376
Wikipage revision ID
1124772344
WikiPageUsesTemplate
Template:Col-begin
Template:Col-break
Template:Col-end
Template:Refimprove
Template:Reflist
Template:Short description