I'm assuming that you meant for a semicolon after arr[i] there else this would fail to compile.
The for loop has 3 statements:
1. The initializer statement ---> i = 0. It initialized i to 0
2. The condition statement ---> This has to evaluate to a boolean.I'll discuss this below.
3. The modification statement ---> This changes something, maybe the loop counter or anything else.
In the example you've shared, arr[i] needs to be evaluated as a boolean. So this would evaluate to arr[i] != 0.
So if we have something like this:
#include <iostream>
int main()
{
int arr[] = {2, 4, 5, 0, 3, 6};
for(int i = 0; arr[i]; i++) {
std::cout<<arr[i]<<'\n';
}
}
The expected output is:
2
4
5
Why? because once i become 3, arr[i] is arr[3] = 0 and the boolean condition arr[i] evalates to false since arr[i] != 0 evaluates to false. I hope that answers your query.