Re:Misconceptions about loops in C
by trealira on Friday June 28, 2024 @07:48AM
(#40819686)
To be symmetric, the loops should read like this:
The second one could also be this:
I say this because your backwards loop accesses the inclusive range [0, n] while your forwards range accesses [0, n - 1].
[ Parent
| on HN ]
for (i = 0; i <= n-1; i++)
for (i = n-1; i >= 0; i--)