+ 8
What is the differance between --x and x--?
challenges made me confused between them .
19 ответов
+ 3
--x has "-- " preceding x which means whenever code runs and it is going to work on x then it will first decrease x by1 and then use it .
but in case of x-- the code will first use the current value of x once and then decrease it with on
it would not decrease x till its current value is used once 😉hope u got it .......
+ 14
Yep, you got it!
int x = 3;
cout << --x; // outputs 2
int y = 3;
cout << y--; // outputs 3, then decrements y
cout << y; // so this outputs 2 now.
+ 11
--x decrements the value first and uses the new value in the statement.
x-- first executes the statement and decrements the value of x after that.
+ 11
You're welcome ^^
+ 8
yeah , I got it . thanks @tashi N 😀
+ 7
so , in --x the new value will be excuted . However x-- the value won't be excuted in the statement . right?
+ 5
good explanation . now I completely can differentiate between them, thank you @Nitish Rawat :)
+ 3
did you change your name .. I thought your name is Nitish
+ 3
good brother ..😃
+ 3
I am now in college.
+ 3
I hope you have nice time in studying
+ 3
engineering .but how did you know?
+ 2
welcome enas 😊
+ 1
actually 😂it is abhishek my younger brother changed it for fun ...
+ 1
its easy to guess . u r in college 1yr . in India first year engineering syllabus has c++
+ 1
I meant than not only in India but mostly everywhere first year engineering has c++
by the way good luck ...
+ 1
for ur engineering dear
0
same here
0
engineering or bsc in computer sciences?