CodesandTutorials
Home   Programming   Hardware   Networking
 
Next generation website theme is here (black, neon and white color) - Reduces eye strain and headache problems.  

C Categories

Assignment Operators

« Previous Point - Relational Operators Next Point - Logical Operators »

Description

The most common assignment operator is equal represented by symbol '=', which assigns or changes the value of left operand to its right operand or expression.

a = a + b;     // adds value of a & b to a

In the above statement 'a' variable is repeated twice, to eliminate such common variables C language offers shorthand way to represent such statements by combining arithmetic operator and assignment operator. Below is the statement that exactly has same effect as one shown above.

a += b;     // adds value of a & b to a

Similarly other assignment operators are

  • -= substraction and assignment
  • *= multiplication and assignment
  • /= division and assignment
  • %= mudulo division and assignment
  • <<= left shift and assignment
  • >>= right shift and assignment
  • &= bitwise AND and assignment
  • ^= bitwise OR and assignment
  • |= bitwise XOR and assignment.

« Previous Point - Relational Operators Next Point - Logical Operators »

Tip Box

Operator precedence

Priority Operator
1st *=
2nd /=
3rd %=
4th +=
5th -=
6th &=
7th ^=
8th |=
9th <<=
10th >>=

Advertisement

Rate Website
   

 


Terms of Use | Privacy Policy | Contact Us
CodesandTutorials © 2014 All Rights Reserved