Why the following code snippet output is 0 6 20 42 72 110
not 0 4 16 36 64 100
?
for(int i=0;i<11;i++){
cout<< i * i++ <<" ";
}
According to C++ Operator Precedence Suffix/postfix increment and decrement has higher precedence than multiplication which means that "i" will be incremented before multiplication.
Edit:
According to Problem with operator precedence question, they said that Operator precedence does not in any way determine the order in which the operators are executed. Operator precedence only defines the grouping between operators and their operands, So how can cout<< i * i++ <<" ";
will be grouped?