Home > Electronics Tutorials > C Language Tutorial > Operators - Assignment

C Language Programming Library Reference Guide

Operators - Assignment

An assignment operator stores the value of the right expression into the left expression. expression1 = expression2
The value of expression2 is stored in expression1.

expression1 *= expression2
The value of expression1 times expression2 is stored in expression1.

expression1 /= expression2
The value of expression1 divided by expression2 is stored in expression1.

expression1 %= expression2
The value of the remainder of expression1 divided by expression2 is stored in expression1.

expression1 += expression2
The value of expression1 plus expression2 is stored in expression1.

expression1 -= expression2
The value of expression1 minus expression2 is stored in expression1.

expression1 <<= shift_value
The value of expression1's bits are shifted to the left by shift_value and stored in expression1.

expression1 >>= shift_value
The value of expression1's bits are shifted to the right by shift_value and stored in expression1.

expression1 &= expression2
The value of the bitwise AND of expression1 and expression2 is stored in expression1.
 
e1 e2 Result
0 0 0
0 1 0
1 0 0
1 1 1

expression1 ^= expression2
The value of the bitwise XOR of expression1 and expression2 is stored in expression1.
 
e1 e2 Result
0 0 0
0 1 1
1 0 1
1 1 0

expression1 |= expression2
The value of the bitwise OR of expression1 and expression2 is stored in expression1.
 
e1 e2 Result
0 0 0
0 1 1
1 0 1
1 1 1
Note: To report broken links or to submit your projects, tutorials please email to Webmaster

Discover

     more......