+ 2

what is the difference between (a++) and (++a) ?

11th Jul 2016, 6:37 PM
Tsige
Tsige - avatar
5 Answers
+ 12
a++ is post increment. which means it evaluates first then increments the value. Ex: int x=2,y; y=x++; //now x=3 and y=2. ++a is pre increment which means it increments first then evaluates. Ex: int x=2,y; y=++x; //now x=3 and y=3.
11th Jul 2016, 6:55 PM
Santhosh
+ 2
a++ is post-increment ++a is pre-increment a=3; console.write("statement print {0}{1}",a++,++a); output 3 4
16th Jul 2016, 2:39 AM
raja RAAK
raja RAAK - avatar
+ 1
@Santhosh thanks
11th Jul 2016, 6:59 PM
Tsige
Tsige - avatar
+ 1
As its name suggests in post increments value will be used first than value will be incremented by one bt in preincrement value will be first incremented and then used.. x++(i. E value+1); ++x(i. e 1+value).;
30th Dec 2016, 1:19 PM
Demo Hi
Demo Hi - avatar
0
Can any explain this program to me int a = 10, b = 10; printf("__a= %d ",__a); printf(b__= % d", b__); out put is __a = 10 b__= 11 how please help me
8th Sep 2016, 11:40 AM
Rami Salim
Rami Salim - avatar