# Arithmetic operators

< c‎ | language
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

C
 Language Standard Library Type support Dynamic memory management Error handling Program utilities Date and time utilities Strings library Algorithms Numerics Input/output support Localization support Thread support (C11) Atomic operations (C11)

C language
General topics
Preprocessor
Keywords
ASCII chart
Escape sequences
History of C
Flow control
Conditional execution statements
Iteration statements
Jump statements
Functions
function declaration
inline specifier
Types
Specifiers
cv specifiers
storage-class specifiers
alignas specifier (C99)
function specifiers (C99)
Literals
 string literals boolean literals(C99)
Expressions
order of evaluation
operators
operator precedence
alternative operators
Utilities
`typedef` declaration
attributes (C99)
casts
Miscellaneous
Inline assembly

Arithmetic operators apply standard mathematical operations to their operands.

Operator Operator name Example Result
+ unary plus +a the value of a
- unary minus -a the negative of a
- subtraction a - b the subtraction of b from a
* product a * b the product of a and b
/ division a / b the division of a by b
% modulo a % b the remainder of a divided by b
~ bitwise NOT ~a the bitwise NOT of a
& bitwise AND a & b the bitwise AND of a and b
| bitwise OR a | b the bitwise OR of a and b
^ bitwise XOR a ^ b the bitwise XOR of a and b
<< bitwise left shift a << b a left shifted by b
>> bitwise right shift a >> b a right shifted by b

Common operators
assignment increment
decrement
arithmetic logical comparison member
access
other

a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b

a(...)
a, b
(type) a
? :
sizeof
_Alignof
(since C11)