In the following program I declared "long" for a, but still getting incorrect negative output after the 1860th term (all are supposed to be positive). What is the cause?
int main()
{
for (int i=1; i<=2000; i++)
{
long a=i*i*i/2-3*i*i/2+3*i-1;
cout << setw(3) << i << "\t" << setw(8) << a << endl;
}
}