a=10;
int z=a–;
cout<<z<<endl;
why we are getting output for above code as same as when we do z=a++
a=10;
int z=a–;
cout<<z<<endl;
why we are getting output for above code as same as when we do z=a++
Hey @ayushtiwari12
int a=10; //initiaize a with 10
int z=a- -; // here we first initialize z with a and then do a-- so z becomes 10 and a becomes 9
int a=10; //initiaize a with 10
int z=a++;// similarlly here we first initialize z with a and then do a++so z becomes 10 and a becomes 11
So if u print a,then that will be different but z will be same.
If it was preincrement/decrement operators then z will be different.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.