#include #include using namespace std; int main() { //The two +'s are both touching the same operand (2). //Which operator gets to sink its teeth into the 2 first? //The left + is executed first //because + has left-to-right associativity. //Precedence doesn't help us here: the two +'s have the same precedence. cout << 1 + 2 + 3 << "\n"; //Outputs 6. //The left - is executed first. //because - has left-to-right associativity. cout << 1 - 2 - 3 << "\n"; //Outputs -4. //Force the right - to be executed first. cout << 1 - (2 - 3) << "\n"; //Outputs 2. return EXIT_SUCCESS; }