What is undefined behaviour?
let an example .... int x=3; cout <<++x*++x; it gives deferent output in different compiler. .gcc gives 25 turbo gives 20 plz give the reason behind it.
.gcc probably processes both postfixes before doing the computation, whereas turbo does it one at a time.
There is the C (or C++) standard, which tells you about how the C language works. The C standard doesn't cover everything though, and so undefined behaviour is born. They do this so writing compilers is easier (and C can run everywhere!). Your example is undefined due to what's called "sequence point rules" - it's a bit tricky, but Keto already said what's happening and the standard doesn't say which compiler is right. The problem is that you have two "side effects" (adding 1 to x) within the same "sequence". As of C++11, sequence point rules have been replaced with "sequenced relations". Your example should still be undefined though, even in gcc, for similar reasons. And Turbo is just old of course so it doesn't know C++11. ___ You can find the technical stuff here. http://en.cppreference.com/w/cpp/language/eval_order https://en.wikipedia.org/wiki/Sequence_point
if I am write in gcc int x=3; cout <<++x*++x*++x; it will gives 150. plz explain. ..... how it will
@Schindlabua: Some behavior is left undefined intentionally so compiler builders can use it to construct better optimizations.
in gcc how it will gives 25 plz explain
This happens because of different compilers evaluate multiple increment operators differently.
Bug: Sololearn notification is still showing number in the notification icon even i did mark as read
Izzy the iguana code coach
Finished python for beginners
Hi, hope you're doing good.Could someone please tell me why does the while loop not stop when I type in rock, paper or scissors?
C++ Question re stringstream
Why sometimes 0 is printed?