C Operators


Defination

Operators in C are symbols or tokens that instruct the compiler to execute calculations, evaluations, or modifications on values or memory units. These tools allow your logic to interact with data directly.


Types of Operators

1. Arithmetic Operators

Used for mathematical handling involving numbers.

SymbolPurposeSample
+Join valuesx + y
-Reduce onex - y
*Multiplyx * y
/Dividex / y
%Find remainderx % y

2. Relational Operators

Establish comparisons between two quantities and return a logical result.

SymbolImplicationInstance
=#ERR520!Checks samenessa == b
!=Validates mismatcha != b
>Larger-than checka > b
<Smaller-than checka < b
>=Greater or equala >= b
<=Lesser or equala <= b

3. Logical Operators

Decide truthfulness based on combined conditions.

SymbolLogic TypeExample
&&All must be truex && y
``
!Reverse boolean!x

4. Assignment Operators

These are used to inject values into containers (variables).

SymbolTaskExample
=Directly storesx = 20
+=Adds, then storesx += 5
-=Subtracts, then storesx -= 2
*=Multiplies, then storesx *= 3
/=Divides, then storesx /= 2
%=Stores leftoverx %= 4

5. Unary Operators

Affect a single operand directly.

OperatorImpactIllustration
++Add one++x or x++
--Subtract one--x or x--
+Affirms sign+x
-Negates sign-x

6. Bitwise Operators

Operate at the individual bit level, enabling low-level data control.

SymbolFunctionSample
&Bitwise ANDx & y
``Bitwise OR
^Bitwise XORx ^ y
~Bit flip~x
<<Bit shift leftx << 2
>>Bit shift rightx >> 2

7. Ternary Operator

A concise method for choosing between two results based on a condition.

Syntax:

(condition) ? result1 : result2;

Sample:

int max = (a > b) ? a : b;

8. Type Conversion Operator

Helps you explicitly switch data types using casting.

Example:

float result = (float)5 / 2;

9. Size and Address Operators

Useful tools to manage memory and type details.

SymbolActionExample
sizeofMeasures byte lengthsizeof(int)
&Acquires memory address&var
*Accesses pointer value*ptr

Important Reminders

  • Use parentheses to control priority.
  • Master the precedence chart to decode which operators take control first in an expression.
  • Using bitwise operators where logical ones are intended can lead to unpredictable and often erroneous outcomes.

Summary Chart

Operator TypeCommon Symbols
Arithmetic+, -, *, /, %
Relational==, =, <, >
Logical&&, `
Assignment=, +=, -=
Unary++, --
Bitwise&, `
Ternary? :
Type Casting(type)
Miscellaneoussizeof, &, *

Prefer Learning by Watching?

Watch these YouTube tutorials to understand C Tutorial visually:

What You'll Learn:
  • 📌 #6: C Operators | [2025] C Programming for Beginners
  • 📌 C_13 Operators in C - Part 1 | Unary , Binary and Ternary Operators in C | C programming Tutorials
Previous Next