#include <limits>
//...
for (int i=0; i<19; i++)
{
int angleInDegrees = i * 5;
if (angleInDegrees == 90)
{
tanArray[i] = std::numeric_limits<double>::quiet_NaN();
}
else
{
tanArray[i]= tan(angleInDegrees * pi / 180);
}
}
EDIT: From what I understand, this gets into implementation-specific nitty-gritty. I don't know how well this code would port across platforms or compilers. This code implies that your platform supports the IEEE 754 floating point standard (which is likely, but not 100% guaranteed).