C Programming operators

0

Operators are Symbol to execute various mathematical or logical operation. C programming has 7 type of operators:

  1. Arithmetic
  2. Relational
  3. Logical
  4. Assignment
  5. Data
  6. Bitwise Operators
  7. Miscellaneous

For learning purpose i tried to memorize some operators. Below i have posted them.

 

C Programming Arithmetic Operator

OperatorMeaningExample
+Additional1+1=2
-Subtract1-1=0
*Multiply3*3=9
/Divide12/3=4
++Increment 1++=2
--Decrement 2--=1

 

C programming Relational Operator

OperatorMeaningExample
=='Equal2==2 is true
!=Not Equal2!=1 is True and 2==1 is False
>Greater Than2>1 Two is grater than 1
<Less than1<2 one is less than two
>=Grater than or Equal2>=2 two is equal
<=Less than or Equal1<=2 One is less than 2

 

C programming Logical Operator

OperatorMeaningExample
&&Both operand should be non-zeroa&&b true
||One of operand is none-zeroa||b True
!Logical Not!(a&&b) True

 

C programming Bitwise Operator

OperatorMeaningExample
&And(c & d)=13
|Or(c | d)=13
^(c ^ d)=13
~Xor(~d)=13
<<Shift leftc<<2=15
>>Shift rightd>>2=12

 

C programming Assignment Operator

OperatorMeaningExample
=Assign EqualA=12
+=Assign Plus-equalB+=A
Result is 24
-=Assign Minus-equalB-=A
Result 0
/=Assign Equal-divide B/=A
Same as B=B/A
*=Assign Equal-multipleB*=A
Same as B=B*A
%=Assign Equal-ModuleB%=A
Same as B=B%A

 

These are the most important operators i am working with mostly. You also can memorize them to write code faster!