C Operators :

Operators and Expressions :

  1. Arithmetic
  2. Relational operators
  3. Logical operators
  4. Increment and Decrement operators
  5. Assignment operators
  6. Conditional operator
  7. Bitwise operators

Arithmetic Operators :

OperatorMeaningExampleResult
+addition5+27
-subtraction5-23
*multiplication5x210
/division5/22
%modulus operator to get remainder in integer division5 % 21

Relational Operators :

OperatorMeaningExampleResult
<less than5<2false
>greater than5>2true
<=less than or equal to5<=2false
>=greater than or equal to5>=2true
==equal to5==2false
!=not equal to5!==2true

Logical Operators :

OperatorMeaningExampleResult
&&logical and(5<2)&&(5>3)false
||logical or(5<2)||(5>3)true
!logical not (negation)!(5<2)true

Note : logical not(!) is unary operator which requires only one operand (true to false and vice versa).

Increment and Decrement operators :

Increment operator (++) is used to increase the value of an integer or char variable.
Decrement operator (--) is used to reduce the value of an integer or char variable.

Examples :

m = 15;
m++ or ++m will produce the result m = 16.

m = 15;
m-- or --m will produce the result m = 14.

Note : That m++ and m-- are referring the post-fix increment and decrement operation, and ++m and --m are referring the prefix increment and decrement operation.

Assignment Operators :

OperatorMeaningExampleResult
+=m += 10m = m + 1025
-=m -= 10m = m - 105
*=m *= 10m = m * 10150
/=m /= 10m = m / 101
%=m %= 10m = m % 105

Conditional Operators :

Conditional operator is used to check a condition and select a value depending on the condition. Normally the selected value will be assigned to a variable which ha the following form.

variable = (condition) ? value 1 : value 2;
When this operator is execute by the computer, the value of the condition is evaluated. If it is true then value 1 is assigned to the variable, otherwise value 2 is assigned to the variable. Consider the following example.

big = ( a > b ) ? a : b
In this operation, the computer checks the value of the condition (a>b); If it is true a is assigned to big; otherwise b is big.

Conditional operator, like assignment operators, is also more concise and more efficient.

Bitwise Operators :

OperatorMeaning
<<shifts the bits to left
>>shifts the bits to right
~bitwise inversion (one's complement)
&bitwise logical and
|bitwise logical or
^bitwise exclusive or

Next Update

Loading...

Currently we improved our website User Interface and other contents. Our next update is adding video tutorials on this site so, We create a new YouTube channel, our YouTube channel name is CodeX.

We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels