+ 2

What is this <-- ? (Anyone explain this for me)

i didn't read about this operator before. First time, i saw it in a challenge. . int a=0; int b=13; while ( b <-- 1) { a++; } cout <<a; output is 12

22nd Apr 2017, 1:53 AM
Code Gun
Code Gun - avatar
8 Answers
+ 11
@bhRT example/ int a = 12; int b = 12; int c = 0; if(b > --a) c++; cout << c; output: 1. I did this with an if statement, I'm assuming you know how it would work in a while loop. (same stuff just looping till false). --a with decrement a then use it. so: if(b > --a) is the same as: if (12 > 11) * the value of a is now 11. * value of b is still 12. If your still confused on --a, take a look at these explanations of what they are: ++x x++ --x x-- https://www.sololearn.com/Discuss/305422/?ref=app
22nd Apr 2017, 2:07 AM
Rrestoring faith
Rrestoring faith - avatar
+ 13
<-- is actually just < --1 It's 2 operators, without the space it looks like one. < is less than. --x decrements x before using it. So while(b<0) // do code ps: I think you wrote the question incorrecly, I'm not sure how a can be 12. Unless I'm missing something that c++ has.
22nd Apr 2017, 1:59 AM
Rrestoring faith
Rrestoring faith - avatar
+ 9
oups lol. I'll edit it to >.
22nd Apr 2017, 2:15 AM
Rrestoring faith
Rrestoring faith - avatar
+ 4
big bro i didn't remember exactly. can you please give me example .
22nd Apr 2017, 2:04 AM
Code Gun
Code Gun - avatar
+ 3
bro in your example if (b <--a) // is false then why output is 1
22nd Apr 2017, 2:15 AM
Code Gun
Code Gun - avatar
+ 3
😂😂😂😂
22nd Apr 2017, 2:16 AM
Code Gun
Code Gun - avatar
+ 1
12
22nd Apr 2017, 12:25 PM
Prince Verma
Prince Verma - avatar
0
bHRT it is (b >--a)
23rd Apr 2017, 5:42 AM
mei
mei - avatar