+ 3
What is ++a?
pls tell me is it simillar to a++
4 Answers
+ 3
++a is prefix increment
while
a++ is postfix increment.
like wise
--a and a--
+ 3
++a is a Pre increament and
a++ is a Post increament.
++a returns the incremented value to another variable. When assign with another variable.
a++ returns the original value to another variable and then variable a is incremented.
+ 3
++a is prefix and a++ is postfix
for e.g
int a=6
b=++a
(then firstly the value of 'a' is increased by 1 and then it is assigned to b.
so the answer is a=7 and b=7)
now a++
int a=6
int b=a++
(here firstly the value of 'a' is assigned to b i.e b=6 then the value of a is increased by 1)
so the answer is a=7 b=6.