2 votes 2 votes int a = 50, b = 50; a = a+++++b; b = b+++++a; Value of b after executing these . I think it should be undefined behaviour. But in answer it is given 155. Can anybody verify it please. Programming in C made-easy-test-series programming-in-c bad-question + – Ankita87077 asked Dec 2, 2021 • reopened Jul 9, 2022 by Arjun Ankita87077 582 views answer comment Share Follow See 1 comment See all 1 1 comment reply raja11sep commented Dec 2, 2021 reply Follow Share It should be undefined behaviour in C. 2 votes 2 votes Please log in or register to add a comment.
–1 votes –1 votes consider the 1st statement, b is pre increment and a is post increment a= 50 + 51 =101 but final value of a will be 102 as post increment simillarly 2nd statement a= 51 + 103 = 154 but final value of b will be 155 as post increment BHOJARAM answered Dec 8, 2021 BHOJARAM comment Share Follow See all 3 Comments See all 3 3 Comments reply ramakrushna commented Dec 23, 2021 reply Follow Share Please correct the statement it should be b = 51 + 103 =154 and after that final value will be 155 due to b bas been post incremented. But nice explanation. Thanks! 0 votes 0 votes SkyAkki commented Jan 6, 2022 reply Follow Share but final value of a will be 102 as post increment Can you explain why it is incrementing to 102? From my understanding I’m getting the answer 153 as follows: a = (a++) + (++b); resulting in a =101 like you. But how come its post incrementing again to 102? Am I missing something? Then finally: b = (b++) + (++a); b= 51 + 102 (a is pre-incremented now) b = 153 Please correct me if I’m wrong. 0 votes 0 votes Arjun commented Jan 6, 2022 reply Follow Share Students always have plenty of time to waste but not to do useful things :) https://gateoverflow.in/62411/Undefined-behaviour-in-c 0 votes 0 votes Please log in or register to add a comment.