I have come across the below C++ program (source):
#include <iostream>
int main()
{
for (int i = 0; i < 300; i++)
std::cout << i << " " << i * 12345678 << std::endl;
}
It looks like a simple program and gives the correct output on my local machine i.e. something like:
0 0
1 12345678
2 24691356
...
297 -628300930
298 -615955252
299 -603609574
But, on online IDEs like codechef, it gives the following output:
0 0
1 12345678
2 24691356
...
4167 -95167326
4168 -82821648
4169 -7047597
Why doesn't the for
loop terminate at 300? Also this program always terminates on 4169
. Why 4169
and not some other value?