I think this is more helpfull than a flowchart
Posted by jared_queiroz@reddit | learnprogramming | View on Reddit | 1 comments
Consider the following expression:
int limit = 9;
for(int i = 3; i <= limit; i++){...}
1. Now let's remove the noise and extract the core logic:
i <= limit ; i++
3 <= 9 ; i++
2. And instead of thinking numerically, lets visualize it:
index ___i_______________ i= 3 Point you choose to start
vector ___i--------------> i ++ Direction for iterations
limit ___i-----<=________ <= 9 End point of the operation
The code runs *FOR* all items in this range: ___i-----<=________
3. Think how do you want to break the operation:
stop before limit?
use <
i, 4, 5, 6, 7, 8 < 9
execute at limit?
use <=
i, 4, 5, 6, 7, 8, 9 <= 9
ElegantPoet3386@reddit
I feel like this is considerably more complicated