C Language Operators - dummies

By Dan Gookin

Part of C All-in-One Desk Reference For Dummies Cheat Sheet

In programming with C, you occasionally want to use common mathematical operators for common mathematical functions and not-so-common operators for logic and sequence functions. Here’s a look at C language operators to use:

Operator, Category, Duty Operator, Category, Duty Operator, Category, Duty
=, Assignment, Equals !=, Comparison, Is not equal to >, Bitwise, Shift bits right
+, Mathematical, Addition &&, Logical, AND ~, Bitwise, One’s complement
–, Mathematical, Subtraction ||, Logical, OR +, Unary, Positive
*, Mathematical, Multiplication !, Logical, NOT –, Unary, Negative
/, Mathematical, Division ++, Mathematical, Increment by 1 *, Unary, Pointer
%, Mathematical, Modulo –, Mathematical, Decrement by 1 &, Unary, Address
>, Comparison, Greater than &, Bitwise, AND sizeof, Unary, Returns the size of an object
>=, Comparison, Greater than or equal to |, Bitwise, Inclusive OR ., Structure, Element access
<, Comparison, Less than ^, Bitwise, Exclusive OR (XOR or EOR) ->, Structure, Pointer element access
<=, Comparison, Less than or equal to <<, Bitwise, Shift bits left ?:, Conditional , Funky if operator expression
==, Comparison, Is equal to