I am just starting out with C++, so my logic is a bit of a poor.
I want to form a for loop which says 'for an integer n; When value of n ranges from [a,b]; increment n by 1 (++n)."
Although I seem to have figured out what went wrong, I just want to exactly know the fault in my logic for a statement (for loop) from my solution:
Incorrect logic:
for (int n = 0; a <= n <= b; ++n) {} /*does not satisfy any test case*/
The above for loop gives me "Wrong output" (In this statement I intend to say: integer n has value 0 (initialized). When n is between a and b, keep incrementing n by 1). How exactly does this differ from the logic I originally want from the for loop (which I have specified at the start of this question)? Do they also consider n =0?
My solution got accepted when I modified the statement to:
Correct Logic:
for (int n = a; n <= b; ++n) {}