0
Why y is not increase by 1 from X value?
#include <iostream> using namespace std; int main() { int x = 11; int y=0; y=x++; cout <<y; return 0; }
2 Antworten
+ 4
Because variable "x" is being post incremented there, which means first the value of "x" would be assigned to "y" and then increment of "x" will take place.
If you want "y" to be assigned after incrementing the value of "x" then you can use pre-increment operation like this " y = ++x "
if you want more detailed difference between x++ and ++x then I would recommend using search bar for the same.
+ 1
Thanks bro!!I got it!!