int x = 5;
x = x++;
cout<<x<<endl; // output is 5 no matter how many times I print x
according to lecture output should be 6.
int x = 5;
x = x++;
cout<<x<<endl; // output is 5 no matter how many times I print x
according to lecture output should be 6.
@vikanshu2016 when you write x++, x does get incremented but it gets assigned the old value, post means use and change, so its value never changes . Check this link for more insight https://stackoverflow.com/questions/7911776/what-is-x-after-x-x