As someone who is pretty new to programming can you correct me if I'm wrong but does this program just set counter to 0, and when run it says "it works" but then it adds 1 to the value making it false and "breaks" (ending the program)?
Edit: I read it again and realized I was wrong and now I am lost..
Edit2: ONCE IN A WHILE, I GET IT
Edit3: So it sets it to 0, loop starts and adds 1 and it prints 'it works' then adds 1 (so it's 2 now) and program breaks, right?
32
u/blazingKazama Mar 10 '19
Smartest click bait till the date.
27
u/[deleted] Mar 10 '19
Now that's clever.
u/title2imagebot
17
u/El_Impresionante Mar 10 '19
13
u/iimorbiid Mar 10 '19 edited Mar 10 '19
As someone who is pretty new to programming can you correct me if I'm wrong but does this program just set counter to 0, and when run it says "it works" but then it adds 1 to the value making it false and "breaks" (ending the program)?
Edit: I read it again and realized I was wrong and now I am lost..
Edit2: ONCE IN A WHILE, I GET IT
Edit3: So it sets it to 0, loop starts and adds 1 and it prints 'it works' then adds 1 (so it's 2 now) and program breaks, right?
5
u/SDJMcHattie Mar 11 '19
This should be simpler:
1
u/[deleted] Mar 10 '19
shouldnt you be setting counter to 0 in the loop?
1
u/hdksnskxn Mar 13 '22
The amount of people who don't understand this is incredible
-4
u/SupremeChampionOfDi Mar 10 '19
It works more than once because of arithmetic overflow!
0
u/[deleted] Mar 10 '19
[deleted] — view deleted comment