# Stupidity and lack of understanding

Go to solution Solved by wanderingfool2,

What was the question?

Generally for loops though the parameters are

starting value

condition to keep going

changing of value

So in cases like i > 0 you should be having the value getting smaller

Going top to bottom here:

1) counts 0.5, 1.5, ... , 11.5 (since it's adding one)

2) Loop keeps going until it rolls over the integer 10, 11, ..., MAX_INT (because starting at 10 and incrementing by 1 each time would make it always greater than 0)

3) Goes from 20, 19,,,,0 (since i >= 0)

4) The one you selected, does run.  Since it starts at i = 0 but i > 10...so 0 > 10, which is false at the very beginning

5) Goes from 0, 1, ..., 9

6) Goes from 1, 3, ... 7, 9 (since starting at 1 and incrementing by 2 each time)

7) Goes from 0, 2, .... 18 (since it starts at 0, increments 2 each time)

can anyone tell me why this is? all the explanations I have found have not helped me

##### Share on other sites

5 minutes ago, Apfelholz said:

can anyone tell me why this is? all the explanations I have found have not helped me

Assuming you're asking why the one was flagged wrong and the other correct, the wrong one is because i starts out <10.  Think of that statement as a While loop.

For the solution marked in green, think of it this way:

Set i to 0

While i is less than 20, i=i+2

Once i >=20, the loop ends

For the incorrect solution

Set i to 0

While i > 10, i=i+1

i isn't greater than 10 to start, so the computer can't start the loop to increment it.

I believe the ones marked in grey are all supposed to be checked (can't read the tags, but the logic is sound)

The first one not marked will never reach 0 because the loop always adds to i, and the other one not marked doesn't increment i at all.

CPU: Ryzen 5 5600X  | Motherboard: ASROCK B450 pro4 | RAM: 2x16GB  | GPU: MSI NVIDIA RTX 2060 | Cooler: Noctua NH-U9S | SSD: Samsung 980 Evo 1T

##### Share on other sites

What was the question?

Generally for loops though the parameters are

starting value

condition to keep going

changing of value

So in cases like i > 0 you should be having the value getting smaller

Going top to bottom here:

1) counts 0.5, 1.5, ... , 11.5 (since it's adding one)

2) Loop keeps going until it rolls over the integer 10, 11, ..., MAX_INT (because starting at 10 and incrementing by 1 each time would make it always greater than 0)

3) Goes from 20, 19,,,,0 (since i >= 0)

4) The one you selected, does run.  Since it starts at i = 0 but i > 10...so 0 > 10, which is false at the very beginning

5) Goes from 0, 1, ..., 9

6) Goes from 1, 3, ... 7, 9 (since starting at 1 and incrementing by 2 each time)

7) Goes from 0, 2, .... 18 (since it starts at 0, increments 2 each time)

3735928559 - Beware of the dead beef

##### Share on other sites

thank you now I have done it right in the nest attempt