+ 1
Could someone provide explaination regarding the working of increment and decrement operations esp. explain the working of below
int a=1; cout<<++a+a++<<endl; //Output is 5 a=1; cout<<(a++)+(++a)<<endl; //Output is 4 a=1; int b=++a + ++a + ++a; cout<<b; //Output is 10 *Please note that the outputs are as received from Dev C++ Compiler Thank You.
2 Respuestas
+ 2
int a=1;
cout<< ++a + a++ <<endl //Output is 5
++a a = 2
2 + a++
2 + 2 ++
2 + 2 + 1
5
a=1;
cout<<(a++)+(++a)<<endl; //Output is 4
(a++) = (1)++ |
(a++) = 1 but after this variable is now 2 here \/
1 + (++a) this one has the increment during so ++a = 3
1 + 3 = 4
Try to understand the third one now I think you got it!