Let us see:
You could do a 'while' loop.
i = 0;
while (i++ < 10)
{
...
}
- OR -
i = 0;
while (i < 10)
{
...
++i;
}
Or a 'do while' loop.
i = 0;
do
{
....
} while (++i < 10);
- OR -
i = 0;
do
{
...
++i;
} while (i < 10);
Or the dreaded 'goto'.
int i = 0;
nextloop:
if (arr[i++] < num)
{
goto nextloop;
}
- OR -
int i = 0;
nextloop:
if (arr[i] < num)
{
++i;
goto nextloop;
}
Or you could create recursive algorithm.
That requires more thought and I am too tired to explain that at the moment.
Note:
Always prefer pre-increment (++i) to post-increment (i++). There are vary valid reasons for this. But don't believe me, research what the creators of the languages have to say on the subject. Or simply draw a flow charts of both post and pre-increment and you will understand why.