C-Operators Tables for Reference

Table of Contents



Types of Operators

Operator Description Example
+ Adds two operands. A + B = 30
- Subtracts second operand from the first. A - B = -10
* Multiplies both operands. A * B = 200
/ Divides numerator by denominator. B / A = 2
% Modulus Operator and remainder after an integer division. B % A = 0
++ Increment operator increases the integer value by one. A++ = 11
-- Decrement operator decreases the integer value by one. A-- = 9



Relational Operators

Operator Description Example
== Checks if the values of two operands are equal. (A == B) is not true.
!= Checks if the values of two operands are not equal. (A != B) is true.
> Checks if the left operand is greater than the right operand. (A > B) is not true.
< Checks if the left operand is less than the right operand. (A < B) is true.
>= Checks if the left operand is greater than or equal to the right operand. (A >= B) is not true.
<= Checks if the left operand is less than or equal to the right operand. (A <= B) is true.



Logical Operators

Operator Description Example
&& Logical AND operator. (A && B) is false.
|| Logical OR operator. (A || B) is true.
! Logical NOT operator. !(A && B) is true.



Bitwise Operators

Operator Description Example
& Binary AND Operator. (A & B) = 12
| Binary OR Operator. (A | B) = 61
^ Binary XOR Operator. (A ^ B) = 49
~ Binary One's Complement Operator. (~A) = -61
<< Binary Left Shift Operator. A << 2 = 240
>> Binary Right Shift Operator. A >> 2 = 15



Assignment Operators

Operator Description Example
= Simple assignment operator. C = A + B
+= Add AND assignment operator. C += A
-= Subtract AND assignment operator. C -= A
*= Multiply AND assignment operator. C *= A
/= Divide AND assignment operator. C /= A
%= Modulus AND assignment operator. C %= A



Misc Operators

Operator Description Example
sizeof() Returns the size of a variable. sizeof(a)
& Returns the address of a variable. &a;
* Pointer to a variable. *a;
?: Conditional Expression. If Condition is true ? then value X : otherwise value Y



Conditional Operators

Operator Description Example
?: Conditional Expression. If Condition is true ? then value X : otherwise value Y

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!