May 14, 2026
Plus-plus? More like plus-chaos
Int a = 5; a = a++ + ++a; a =? (2011)
This tiny math line sparked an old-school nerd meltdown over trick questions and bad code
TLDR: This old code puzzle has three possible answers because the language rules leave the result unclear on purpose. Commenters were far more interested in roasting the idea itself, calling it a tired interview trap and the kind of code that should get you side-eyed immediately.
A single line of code from 2011 has somehow done what internet discourse does best: turn a simple-looking puzzle into a full-blown comment-section food fight. The setup is deceptively innocent — start with 5, mix in some sneaky plus-plus operators, and ask what number comes out. The punchline? Depending on how a compiler handles it, the answer can be 11, 12, or 13. In normal-person terms: the computer language rules are fuzzy here, so different systems can legally do different things. Chaos, but make it educational.
And the community? Absolutely exhausted, amused, and lightly traumatized. One camp groaned that this is exactly the kind of gotcha question that keeps showing up in coding interviews like a horror villain that never dies. Another rolled their eyes so hard you could hear it through the screen, basically calling this the most stereotypical programmer blog topic imaginable: yes, another “plus-plus” brain teaser, yes, another argument about ordering rules. But not everyone was cynical. One commenter was genuinely baffled that the language even allows this mess, asking why nobody just made the behavior clearly defined in the first place.
Then came the killer line from the peanut gallery: “If you write this you are fired.” That comment stole the show and summed up the mood perfectly. The real verdict wasn’t 11, 12, or 13 — it was: don’t write cursed code and expect sympathy.
Key Points
- •The article analyzes `int a = 5; a = a++ + ++a;` as a case of undefined behavior in C/C++.
- •It identifies two separate sources of undefined or compiler-dependent behavior: operand evaluation order and the handling of post-increment in assignments.
- •Theoretical execution paths in the article produce three possible final values for `a`: 11, 12, and 13.
- •The post explains the `a = a++;` case using a memory-copy model to show how post-increment may be overwritten or applied later.
- •A compiler results table compares outputs for several related increment expressions across gcc, tcc, bcc, and Microsoft C/C++ environments.