C Programming Language


Operator


Assignment Operator :

The following table shows the Assignment operators:

Operator Descriptions Example
= Assignment operator, Assigns values from right operand to left operand R = P + Q will assign value of P + Q to the R
+= Add tion assignment operator, It adds right to the left and assign the result to left variable R += P is equals to R = R + P
-= Subtraction assignment operator, It subtracts right from the left and assign the result to left Variable R -= P is equals to R = R - P
*= Multiplication assignment operator, It multiplies right with the left and assign the result to left variable R *= R is equals to R = R * P
/= Division P assignment operator, It divide left with the right and assign the result to left variable R /= P is equals to R = R / P
%= Modulo assignment operator, It takes modulus using two variable and assign the result to left variable R %= R is equivalent to R = R % P
<<= Left shift assignment operator R <<= 3 is same as R = R << 3
>>= Right shift assignment operator R >>= 3 is same as R = R >> 3
&= Bitwise assignment operator R &= 4 is same as R = R & 4
^= bitwise exclusive OR assignment operator R ^= 4 is same as R = R ^ 4
|= bitwise inclusive OR assignment operator R |= 5 is same as R = R | 5

Example :

Output :

Line 1 - = Operator, Value of z = 21
Line 2 - += Operator, Value of z = 42
Line 3 - -= Operator, Value of z = 21
Line 4 - *= Operator, Value of z = 441
Line 5 - /= Operator, Value of z = 21