The C operators fall into the following categories:
A D V E R T I S E M E N T
Postfix operators, which follow a single operand only.
Unary prefix operators, which precede with a single operand.
Binary operators, which take two operands and perform a variety
of logical and arithmetic operations.
The conditional operator (a ternary operator), which takes three
operands and evaluates either the second or third expression,
depending on the evaluation of the first expression only.
Assignment operators, which only assign a value to a variable.
The comma operator, which gives guarantees left-to-right evaluation of
comma-separated expressions.
To create more complex expressions,variables and constants can be used in conjunction with C operators.
The following tables describes different operators available in c
Operator
Example
Description/Meaning
()
f()
Function call
[]
a[10]
Array reference
->
Structure and union member selection
.
s.a
Structure and union member selection
+ [unary]
+a
Value of a
- [unary]
-a
Negative of a
* [unary]
*a
Reference to object at address a
& [unary]
&a
Address of a
~
~a
One's complement of a
++ [prefix]
++a
The value of a after increment
++ [postfix]
a++
The value of a before increment
- - [prefix]
-a
The value of a after decrement
- - [postfix]
a-
The value of a before decrement
sizeof
sizeof (t1)
Size in bytes of object with type t1
sizeof
sizeof e
Size in bytes of object having the type of expression e
+ [binary]
- [binary]
* [binary]
/ %
a + b
a - b
a * b
a / b
a % b
a plus b
a minus b
a times b
a divided by b
Remainder of a/b
>>
<<
a >> b
a << b
a, right-shifted b bits
a, left-shifted b bits
<
>
<=
>=
==
!=
a < b
a > b
a <= b
a >= b
a == b
a != b
1 if a < b; 0 otherwise
1 if a > b; 0 otherwise
1 if a <= b; 0 otherwise
1 if a >= b; 0 otherwise
1 if a equal to b; 0 otherwise
1 if a not equal to b; 0 otherwise
& [binary]
|
^
a & b
a | b
a ^ b
Bitwise AND of a and b
Bitwise OR of a and b
Bitwise XOR (exclusive OR) of a and b
&&
||
!
a && b
a || b
!a
Logical AND of a and b (yields 0 or 1)
Logical OR of a and b (yields 0 or 1)
Logical NOT of a (yields 0 or 1)
?:
a ? e1 : e2
Expression e1 if a is nonzero;
Expression e2 if a is zero
=
+=
-=
*=
/=
%=
>>=
<<=
&=
|=
^=
,
a = b
a += b
a -= b
a *= b
a /= b
a %= b
a >>= b
a <<= b
a &= b
a |= b
a ^= b
e1,e2
a, after b is assigned to it
a plus b (assigned to a)
a minus b (assigned to a)
a times b (assigned to a)
a divided by b (assigned to a)
Remainder of a/b (assigned to a)
a, right-shifted b bits (assigned to a)
a, left-shifted b bits (assigned to a)
a AND b (assigned to a)
a OR b (assigned to a)
a XOR b (assigned to a)
e2 (e1 evaluated first)
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
Keywords:
c operators,
c programming operators,
c bitwise operators,
c bit operators,
c language operators,
c binary operators,
c operator,
c++ operators'
'
operator in c,
c operator precedence,
operators in c,
operators c,
bitwise operators in c,
c# operators