C++ Assignment Operators

C++ Assignment Operators


Define :
  • C++ Assignment Operators
The simple assignment operator is denoted by ‘=’. We are called it that both the left and right sides of the operator must have the same data type. We have different levels of assignment operators as shown below.

Operator

Example

Same as

=

a = b

a = b

+=

a += b

a = a+b

-=

a -= b

a = a-b

*=

a *= b

a = a*b

/=

a /= b

a = a/b

%=

a %= b

a = a%b

     

Example :

Output :