1 votes 1 votes #include<stdio.h> main() { int j=0; int i; for( i=0;i<100;i++) { j=j++; } printf("%d",j); } why o/p is zero?? Ajeet Singh asked Jun 24, 2018 Ajeet Singh 1.4k views answer comment Share Follow See all 3 Comments See all 3 3 Comments reply Shubhgupta commented Jun 24, 2018 reply Follow Share answer is compiler dependent on gcc it is giving 0 and on turbo c it is giving 100. 0 votes 0 votes anonymous commented Jun 24, 2018 reply Follow Share This program output will give the ans 0 try it as j=j+1 then it will give answer as 100. So it means that it only doing 0++ in gcc compiler 0 votes 0 votes Shubhgupta commented Jun 24, 2018 reply Follow Share https://gateoverflow.in/62411/undefined-behaviour-in-c check other examples for undefined behaviour. 1 votes 1 votes Please log in or register to add a comment.
0 votes 0 votes Every time value of j taht is zero assign to itself j before the increment j=j++;//at this line zero is assign first then increment and every time j is assign by zero // so the final output will be zero RAGHAV* answered Oct 10, 2018 RAGHAV* comment Share Follow See all 0 reply Please log in or register to add a comment.