Assignment Operators

Let's take a look at the assignment operator and a few related shorthands.

Introduction

We have already seen the assignment operator, which is used to assign a value to a variable or update its value. The “equal to” sign(=) is used for this operator. Anything on the right of = is assigned to the variable on its left.

Therefore, you always need to place a variable on the left side of =, whereas on the right side can be a value or another variable. Another thing you need to be careful about is the type. You can assign a double value or another double type variable only to a double type variable.

Let’s look at some use cases of the assignment operator.

Get hands-on with 1200+ tech skills courses.