1 votes 1 votes what will be the output of the following piece of code? void add() { int i=11; printf("%d",++i|i++); } Programming in C programming + – Mehraj asked Mar 18, 2018 retagged Mar 29, 2018 by Sukanya Das Mehraj 408 views answer comment Share Follow See 1 comment See all 1 1 comment reply Raj Kumar 7 commented Mar 18, 2018 reply Follow Share It totally depends on the compiler. Try it you get more idea printf( "%d", i, ++i | i++); 0 votes 0 votes Please log in or register to add a comment.
–2 votes –2 votes answer is 12. ++i will execute first so i becomes 12. i++ will execute next .here i is still 12 because of post incrementation. then | will exectue . binary of 12 is 0000 1100 . priority is ++i(pre increment) > i++(post increment) > | (bitwise or) 12 | 12 =12 . praveen sankar answered Mar 19, 2018 edited Mar 19, 2018 by praveen sankar praveen sankar comment Share Follow See all 2 Comments See all 2 2 Comments reply Mehraj commented Mar 19, 2018 reply Follow Share @praveen Shankar,I am getting the same answer by same concept but the answer on system is 13 0 votes 0 votes praveen sankar commented Mar 19, 2018 reply Follow Share I am getting 12 in my system and 13 in online platforms. so we could say that some compilers give 12 for i++ and others give 13 for i++. Depending on how compilers treat i++ answer will be 12 or 13. 0 votes 0 votes Please log in or register to add a comment.