2 votes 2 votes Consider the following program: The value printed by the above program is: 1. 20 2. 30 3. 40 4. 50 I think it will be undefined behaviour because of: arr[count++] = incr(); But I am not sure. need to confirm. Programming in C programming programming-in-c made-easy-test-series madeeasy-testseries-2018 + – Rishabh Gupta 2 asked Jan 15, 2018 • edited Mar 5, 2019 by ajaysoni1924 Rishabh Gupta 2 678 views answer comment Share Follow See all 9 Comments See all 9 9 Comments reply Mk Utkarsh commented Jan 15, 2018 reply Follow Share i also thought so but it works fine 0 votes 0 votes Anu007 commented Jan 15, 2018 reply Follow Share I dont think so i think it will be evaluated as arr[count++] evaluated after incr() evaluated. 0 votes 0 votes Rishabh Gupta 2 commented Jan 15, 2018 reply Follow Share @Anu see Example 2 at the end of this selected answer: https://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points 0 votes 0 votes Anu007 commented Jan 15, 2018 reply Follow Share Rishabh a[count++] = ++count ; has confusion which to acsess 1st , so undefined behaviour. But in given program we force ++count to evaluate 1st . 0 votes 0 votes Rishabh Gupta 2 commented Jan 15, 2018 reply Follow Share So, does that mean if we have a function call it will be evaluated first? Do you have any source to read this? 0 votes 0 votes Kiran Karwa commented Jan 15, 2018 reply Follow Share Wouldn't it be 30? 0 votes 0 votes Rishabh Gupta 2 commented Feb 3, 2018 reply Follow Share @kiran Yes answer will be 30. And arr[0] = 2 0 votes 0 votes vijju532 commented Mar 20, 2018 reply Follow Share finally what will be the ans ??coz i am also confused 0 votes 0 votes Markzuck commented Nov 27, 2018 reply Follow Share @Rishabh Gupta shouldn't it be arr[0] = 1 as it will store the value returned by the function call incr() which is 1 and then count++ makes value of count as 2 to be used in the next printf statment? 0 votes 0 votes Please log in or register to add a comment.