Pre and post operaters

#include
using namespace std;
int main()
{
int a=4;
cout<<a++<<a–<<++a<<–a<<a*a<<endl;
}
i did this ques in sublime text and the output was 344416
but when i did this on coding blocks on coding blocks IDE i got a different answer
link to it is

sir i am too confused after thinking over this
plzz explain me the how the flows goes and what would be the correct answer.

The correct answer is 455416

a++ returns the value of ‘a’ before the value of ‘a’ is incremented and ++a first increases the value of ‘a’ by 1 and then returns the incremented value of ‘a’.

In the same manner, a-- first returns the value of ‘a’ and then decreases its value by 1 and --a first decreases the value of ‘a’ by 1 and then returns the decreased value.

So,

a++=4 // a = 5
a–=5 //a = 4
++a=5 //a = 5
–a=4 //a = 4
a*a=16 //a=4

Hope this would clear your concept, if you still have doubts feel free to ask.

sir i understand what u r saying
but why it is showing different output in sublime text

i checked this in codeblocks also it shows the answer is 344416

i had this doubt earlier also and someone told me compiler checks from right to left
so value of a is checked and changed as we move from right to left in this instruction
iread associativity of ++ and – operator is from right to left
maybe that is creating the difference.

int a=4;
cout<<a++<<a–<<++a<<–a<<a*a<<endl;
it is checked and finalised and then operations are applied on that value of a and they are printed from left to right
so sir please look into that as well
and please clear my confusion

the way u have done u have directly applied operations on a fr0m left to right and kept changing values of a accordingly and printed them.
but i am confused sir.

Associativity is taken into account if the operators have same precedence.

But here the prefix operator has lower precedence to postfix operation.

Their associativity is also different. Associativity of postfix ++ is left to right and associativity of prefix ++ is right to left.

Thus, the output can vary from compiler to compiler

The output is undefined as the order of evaluation is not mandated by standard. The compiler is free to evaluate. Only when equal level precedence operators appear in an expression, the associativity comes into picture.

This is called as undefined behavior, and is dependent on what compiler you use, to better understand this you have to know computer architecture and how compiler works.