C Operators
In C programming language, operators are used to perform different operations on data values. There are various types of operators, such as arithmetic, relational, logical, bitwise, assignment, conditional, and increment/decrement operators. In this table, we will discuss each type of operator in detail:
Operator | Description | Example |
---|---|---|
Arithmetic Operators | Used to perform mathematical operations | + , - , * , / , % |
Relational Operators | Used to compare two values | > , < , >= , <= , == , != |
Logical Operators | Used to combine two or more conditions | && , ` |
Bitwise Operators | Used to perform operations on binary values | & , ` |
Assignment Operators | Used to assign values to variables | = , += , -= , *= , /= , %= , &= , ` |
Conditional Operators | Used to make decisions based on conditions | ? : |
Increment/Decrement Operators | Used to increment or decrement the value of a variable | ++ , -- |
Arithmetic Operators:
Arithmetic operators are used to perform mathematical operations. The table below shows the arithmetic operators in C programming language:
Operator | Description | Example |
---|---|---|
+ | Addition | a + b |
- | Subtraction | a - b |
* | Multiplication | a * b |
/ | Division | a / b |
% | Modulo | a % b |
Relational Operators:
Relational operators are used to compare two values. The table below shows the relational operators in C programming language:
Operator | Description | Example |
---|---|---|
> | Greater than | a > b |
< | Less than | a < b |
>= | Greater than or equal to | a >= b |
<= | Less than or equal to | a <= b |
== | Equal to | a == b |
!= | Not equal to | a != b |
Logical Operators:
Logical operators are used to combine two or more conditions. The table below shows the logical operators in C programming language:
Operator | Description | Example |
---|---|---|
&& | Logical AND | a && b |
` | ` | |
! | Logical NOT | !a |
Bitwise Operators:
Bitwise operators are used to perform operations on binary values. The table below shows the bitwise operators in C programming language:
Operator | Description | Example |
---|---|---|
& | Bitwise AND | a & b |
` | ` | Bitwise OR |
^ | Bitwise XOR | a ^ b |
~ | Bitwise NOT | ~a |
<< | Left shift | a << b |
>> | Right shift | a >> b |
Assignment Operators:
Assignment operators are used to assign values to variables. The table below shows the assignment operators in C programming language:
Operator | Description | Example |
---|---|---|
= | Simple assignment | a = b |
+= |