Consider below C++ program and predict its output.
The above invokes undefined behaviour by referencing both ‘i’ and ‘i++’ in the argument list. It is not defined in which order the arguments are evaluated. Different compilers may choose different orders. A single compiler can also choose different orders at different times.
For example below three printf statements may also cause undefined behavior.
Therefore, it is not recommended Not to do two or more than two pre or post increment operators in the same statement.
This means that there’s absolutely no temporal ordering in this process. The arguments can be evaluated in any order, and the process of their evaluation can be intertwined in any way.
This article is contributed by Spoorthi Aman. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Nested printf (printf inside printf) in C
- What is use of %n in printf() ?
- How to print % using printf()?
- Use of & in scanf() but not in printf()
- Passing NULL to printf in C
- Cin-Cout vs Scanf-Printf
- What is the difference between printf, sprintf and fprintf?
- How to change the output of printf() in main() ?
- puts() vs printf() for printing a string
- Return values of printf() and scanf() in C/C++
- Operators in C | Set 2 (Relational and Logical Operators)
- Measure execution time of a function in C++
- Measure execution time with high precision in C/C++
- Operators in C | Set 1 (Arithmetic Operators)
- Operators in C / C++
- # and ## Operators in C
- Assignment Operators in C/C++
- unordered_set operators in C++ STL
- C | Operators | Question 26
- C | Operators | Question 18
Improved By : ArunSivaramakrishnanS