# int a=2; printf("%d", ++a + a++);

+8 votes
asked Jun 18, 2019

## 37 Answers

+3 votes
answered Jun 19, 2019 by anonymous

# int a=2; printf("%d", ++a + a++);

answer is:6
commented Jun 21, 2019 by (100 points)
right ans is 6
commented Jun 26, 2019 by (110 points)
yaa right answer is 6 bcz first it will make a = 3 bcz of preincrimnet and the it will add 3 to 3 as a++ is post increment so it's answer will be 6
commented Jun 27, 2019 by anonymous
correct answer is 6
commented Jul 1, 2019 by gowtham
first a is incremented by one because that ++a first interment then stored a++ is first stored then is incremented.so 2 incremented 3 now a value is 3 then a++ first stored 3 does not incremented so 3+3=6.
commented Jul 3, 2019 by (100 points)
the answer is 7 because when u code this the answer is shown as 7, this is because the first incrimination (++a) is 3 then the second one becomes 4 as a=3 for the second incrimination so it becomes 3+4=7
commented Jul 4, 2019 by anonymous
3+3=6
A= 4 AFTER EXECUTION
commented Dec 22, 2019 by (560 points)
no the out put will be a garbage value
commented Jan 24, 2020 by (100 points)
It will be the 7.
0 votes
answered Jun 20, 2019 by anonymous
'5' will be the answer.
0 votes
answered Jun 20, 2019 by anonymous
'7' is the answer.
0 votes
answered Jun 20, 2019 by (140 points)
6 is the answer
0 votes
answered Jun 20, 2019 by half_deadlock
5

++a define a=a+1, So it's value is a=3

a++ define only a+1 but it noe store into a so value of a is 2

so 3+2=5

so final answer is 5
commented Jun 21, 2019 by anonymous
Sorry to say but you are wrong.
Value of a is 2 at first
For ++a, the value of a is icremented by 1 immediately,so it becomes a=2+1=3
++a=3
So, the new value of a is 3 now
the trickiest part now ---------
therefore, (++a)+(a++) = 3 + 4 = 7
so 7 will be the answer
0 votes
answered Jun 22, 2019 by (140 points)
output of this is 5
0 votes
answered Jun 22, 2019 by (180 points)
Output for this is 7

a has value 2 the it get incremented as 3 add to the post incremented value 4 then the answer is absolutely 7.
0 votes
answered Jun 22, 2019 by (140 points)
initially pre-increment operation occurs, ++a=3, then substiution of the values takes place,i.e (++a + a++)=(3 + 3) =6 then post increment occurs hence a becomes 7

the ans is 7
0 votes
answered Jun 25, 2019 by Harshit 1 flag
ANSWER is 6 because 3+3=6
0 votes
answered Jun 25, 2019 by (140 points)
answer will be 7