+ 1
[c++] please explain me why the answer is 2
int c,j=0,n=0; for(c=1;c<=5;c++){ j=j++; } n=j+2; j=n; cout<<j;
3 Answers
+ 2
Because, loop does not increase j value. j++ means it will increase value of j by 1 on next cycle. But j=j++, does not increase its value. After that n=j+2; it make n = 2. At last j=n. So, j =2 as output
+ 4
@Aditya
this should work according to you but it is not working
https://code.sololearn.com/ciBxIDas5kx9/?ref=app
0
it will be 6