Variants of assignment operator

Earlier in the chapter, you learned about the assignment operator, =. Now, we will see some more variants of the assignment operator, often used in combination with arithmetic operators:

Operator

Description

=

x=y , y is assigned to x

+=

x+=y is equivalent to x=x+y

-=

x-=y is equivalent to x=x-y

*=

x*=y is equivalent to x=x*y

/=

x/=y is equivalent to x=x/y

**=

x**=y is equivalent to x=x**y

Here, we will look at a few examples of the variants of the assignment operator:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.199.184