So in theory this for loop is suppose get the words first letter and check if it matches any other letters in the same word. If there are no matching letters then the word is classed as an Isogram.
I’m confused how the the results of this for loop is 1,2,3,4 exactly.
So when the first loop runs, Index is 0 then 1 is added to index making it 1. After this point I get lost and don’t understand. Does Comparison++ even do anything in the first loop because its a post-increment? and how does it effect the code when runs in the 2nd and the other loops.
If someone could break it down for me and explain I would really appreciate it!
First, you did declare the default value for Comparison which is Comparison = Index + 1;. The index is 0 so this results in Comparison to be 1. Then you did write Comparison++ which adds 1 after every loop.
In your code, the first loop is going to be the default value 1 and then it just adds 1 after every loop so it ends up being 1,2,3,4. I hope this helps.
I would probably change that for loop as Index doesn’t need to be in there. You can do that before it with bIsogram. There’s also no point in doing = Index + 1 when Index is always 0.
I’m sure these things are confusing you.
A typical for loop is
for (int i = 0; i < n; i++) {}
In this example, i starts at 0 and increments by 1 each time the for loop runs as long as each new loop through it is less than n. i doesn’t go to 0 each time and the first run is 0.