The following short program is obvious wrong (it's taken from the book "How Not
To Program In C++" by Steve Oualline, p.15):
int main()
{
// An array for the squares
int array[5];
int i; // Index into the array
for (i = 1; i <= 5; ++i) {
array[i] = i*i;
}
for (i = 1; i <= 5; ++i) {
std::cout << i << " squared is " <<
array[i] << '\n';
}
return (0);
}
But the program gives the (correct) result:
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25
when run in Eclipse with cygwin?