Hahah! Thats how I get the ladies.... being a newb at life. Fair enough to you both. Especially citizen for taking the moral high road.
Can I challenge you through frivelous bets too? I bet you can't explain how this function works, Yi. And notice I am addressing a single person and not everyone on the forum?
Example:
Code:
#include <math.h>
#include <float.h>
#ifndef M_PI
# define M_PI (3.14159265358979323846)
#endif
#ifndef M_2PI
# define M_2PI (6.28318530717958647692)
#endif
struct trig_table
{
double sin, cos, tan, csc, sec, cot;
};
struct trig_table *create(int ndegrees)
{
double nrads = (double)ndegrees * M_PI / 180.0, count;
int ticks = (int)floor((M_2PI / nrads) + 0.5), i;
struct trig_table *table = malloc(sizeof(*table) * ticks);
if(!table)
return 0;
for(i = 0, count = 0.0; i < ticks; ++i, count += nrads)
{
table[i].sin = sin(count);
table[i].cos = cos(count);
table[i].tan = tan(count);
table[i].csc = (table[i].sin)? 1.0 / table[i].sin : NAN;
table[i].sec = (table[i].cos)? 1.0 / table[i].cos : NAN;
table[i].cot = (table[i].tan != NAN) ? ((table[i].tan)? 1.0 / table[i].tan : NAN) : 0.0;
}
return table;
}
Yi, what does that function do? And does it usefully demonstrate the use of arrays? Or was it a waste of time. Explain either answer.