C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples Assignment Operations in C++ programming language Assignment Operations in C++ programming language The operator "=" is an assignment operator in C++ and it assigns a value to the objects on the left. C++ provides capability to combine assignment operator with almost all the operation we have discussed above and forms a "Composite Assignment Operator". For example we can add a value to a variable as shown below int k = 9; //normal way of adding value k = k + 7; //you can add value in a more compact way by combining two operators //Composite assignment will be k += 7; // this is equal to k = k + 7 Let X = 10 initially for the below examples Composite Assignment Operator Example Is Equivalent to Output += X += 2 X = X + 2 12 -= X -= 2 X = X - 2 8 *= X *= 2 X = X * 2 20 /= X /= 2 X = X / 2 5 %= X %= 2 X = X % 2 0 <<= X <<= 2 X = X << 2 40 >>= X >>= 2 X = X >> 2 2 &= X &= 2 X = X & 2 2 ^= X ^= 2 X = X ^ 2 8 |= X |= 2 X = X | 2 10