Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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

+8 votes
asked Jun 18, 2019 by kj

37 Answers

0 votes
answered Jul 4, 2019 by anonymous
Answer is 6.
0 votes
answered Jul 5, 2019 by anonymous
answer would be 6
0 votes
answered Jul 6, 2019 by anonymous
a=2
++a=2+1=3
a++=3
++a+a++=3+3=6
0 votes
answered Jan 17, 2020 by Warisha Laique (320 points)
++a=3

a++=2

++a + a++ =3+2 =5

output:5
0 votes
answered Jan 20, 2020 by VINIT SAMMIR (250 points)
6, beacuse first increase and after then add icrease value
3+3=6
0 votes
answered Jan 23, 2020 by Ramesh Yedage (150 points)
int a=2;

a++=2+1=3

++a=3
0 votes
answered Jan 27, 2020 by Parth Ahluwalia
this is a problem of post and pre increment so the answer is 6
0 votes
answered Jan 31, 2020 by teja sree (380 points)
answer is:6 first it  is preincrement so the value is incremented and assigned to a. Next as it is post increment it assigns the value and the value of a will be incremented.
0 votes
answered Feb 2, 2020 by VINIT SAMMIR (250 points)
the ans is seven beacuse first it check right and thencheck left
0 votes
answered Feb 3, 2020 by Aparna Tripathi (180 points)
++a=3,a++=2

i.e 5
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...