What are assignment operators?
Following are the two basic types of assignment operators.
- Simple assignment Operator
- Compound assignment Operator
y=x //Here I am assigning the value of x to y so y would be 10
//Here I am trying to compare the two values with each other like I want to check if the value stored //in x is equals to the value stored in y
In += assignment operator we generally do the two steps work in a single step. For example I want to assign a value to a variable with an increment of 3 I would do it in one single step instead of assigning a simple value to a variable first and then adding three to it and storing it.
A good programmer always write short codes for bigger problems to improve the runtime speed of the software.
There might be a question rise into your mind. Is += and =+ are same?
Buy on amazon with upto 40% off