0

using 16 bit compiler e.g turbo c++

int a = 10; 
cout << a << a++ << ++a; 

Output 121111

When using 32/64 bit compiler or any online compiler

Output: 101012

Why this is happening I'm aware about associativity and precedence is it due to the compiler version or c++ version ?

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • (The short version of Taekahn's link is that the execution of operand expression for most binaries operation, beside logical ones, is *undefined* -- that is, left for the implementation to decide, and thus can vary *from compiler to compiler* or even from a version to another.) – Alceste_ Sep 10 '22 at 04:12
  • Don't waste your time on Turbo C++. It is obsolete (has been for more than ~25 years) and pre-standard - noone use it anymore. You will just learn bad habits and obsolete techniques. Invest your time in learning modern C++ instead. – Jesper Juhl Sep 10 '22 at 06:55
  • @JesperJuhl -- while that's true (although a bit annoying to those of us who developed Turbo C++ ), the problem in the question doesn't come from using an old compiler. – Pete Becker Sep 10 '22 at 13:30
  • Is it due to the c++ versions ? – Abhishek kumar Sep 11 '22 at 05:41

0 Answers0