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.

Terms of Use | Privacy Policy | Contact Us | Advertise

CodesandTutorials © 2014 All Rights Reserved