Why output is 252 instead of 210? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why output is 252 instead of 210?

For C++ : What's the logic for 252 here? https://code.sololearn.com/c2b2fqv6fn71/?ref=app

23rd Oct 2017, 2:07 PM
Jaya Goswami
5 Answers
+ 7
The compiler (gcc) is resolving 6*6*7 and not 5*6*7: int i=4,x; x=++i* ++i* ++i; Another compiler might do something different. Multiple pre/post operators, in one statement on a variable, land in one sequence point and result in undefined (means: compiler-specific) behavior.
23rd Oct 2017, 2:43 PM
Kirk Schafer
Kirk Schafer - avatar
+ 4
If you still have questions after reading this just ask. Also this website is a great source of info for C++. http://en.cppreference.com/w/cpp/language/eval_order
3rd Nov 2017, 3:09 AM
Bob
Bob - avatar
+ 3
Regardless of the output (matching or not), output depends on the compiler; it is unreliable. [edited]
23rd Oct 2017, 3:43 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
So we'll have different values for same code of c++ on different compilers.??
23rd Oct 2017, 3:28 PM
Jaya Goswami
0
@jaya I think no !!
2nd Nov 2017, 11:42 AM
Rishabh
Rishabh - avatar