As I mentioned in the title,
What is the difference between a += b and a =+ b , also a++ and ++a ? I'm little confused
If A and B are two sets, then their difference is given by A - B or B - A. A - B means elements of A which are not the elements of B. Solved examples to find the difference of two sets: 1.
Definition. Type A blood has A antigens and anti-B antibodies. Type B blood has B antigens and anti-B antibodies. AB blood has AB antigens, and no antibodies and type O blood has no antigens but both anti-A and anti-B antibodies.
When someone refers to the difference between A and B, it usually does not imply there is only one difference! The difference, often with the emphasized in some way, spoken or written, means the most important difference.
Difference of Two Sets Symbolically, we write A – B and read as “ A minus B”.
a += b
is equivalent to a = a + b
a = +b
is equivalent to a = b
a++
and ++a
both increment a
by 1. The difference is that a++
returns the value of a
before the increment whereas ++a
returns the value after the increment.
That is:
a = 10; b = ++a; //a = 11, b = 11 a = 10; b = a++; //a = 11, b = 10
a += b
is equivalent to a = a + b
a = +b
is equivalent to a = b
a++
is postfix increment and ++a
is prefix increment. They do not differ when used in a standalone statement, however their evaluation result differs: a++
returns the value of a
before incrementing, while ++a
after. I.e.
int a = 1; int b = a++; // result: b == 1, a == 2 int c = ++a; // result: c == 3, a == 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With