C Programming Operators

C has a variety of operators that are used to perform various operations in a program. These operators can be broadly classified into six categories: arithmetic operators, assignment operators, comparison operators, logical operators, bitwise operators, and others.

Arithmetic Operators

Arithmetic operators are used to perform arithmetic operations such as addition, subtraction, multiplication, division, and others. The following table lists the arithmetic operators in C and their descriptions along with examples:

NameDescriptionExample
+Additionx + y
-Subtractionx - y
*Multiplicationx * y
/Divisionx / y
%Modulusx % y

Assignment Operators

Assignment operators are used to assign values to variables. The following table lists the assignment operators in C and their descriptions along with examples:

NameDescriptionExample
=Assignmentx = y
+=Addition Assignmentx += y
-=Subtraction Assignmentx -= y
*=Multiplication Assignmentx *= y
/=Division Assignmentx /= y
%=Modulus Assignmentx %= y

Comparison Operators

Comparison operators are used to compare values and return a Boolean value indicating the result of the comparison. The following table lists the comparison operators in C and their descriptions along with examples:

NameDescriptionExample
==Equal Tox == y
!=Not Equal Tox != y
>Greater Thanx > y
<Less Thanx < y
>=Greater Than or Equal Tox >= y
<=Less Than or Equal Tox <= y

Logical Operators

Logical operators are used to perform logical operations such as AND, OR, and NOT. The following table lists the logical operators in C and their descriptions along with examples:

NameDescriptionExample
&&Logical ANDx && y
||Logical ORx || y
!Logical NOT!x

Bitwise Operators

Bitwise operators are used to perform operations on individual bits of a binary number. The following table lists the bitwise operators in C and their descriptions along with examples:

NameDescriptionExample
&Bitwise ANDx & y
|Bitwise ORx | y
^Bitwise XORx ^ y
~Bitwise NOT~x
<<Left Shiftx << y
>>Right Shiftx >> y