floating.c
changeset 63 5a82f89d607e
parent 29 7abf6146898e
child 77 49e0babccb23
equal deleted inserted replaced
62:b7061c0e239f 63:5a82f89d607e
     5 
     5 
     6 #include <stdio.h>
     6 #include <stdio.h>
     7 #include <stdlib.h>
     7 #include <stdlib.h>
     8 #include <math.h>
     8 #include <math.h>
     9 
     9 
    10 double *getValues (int elements)
    10 double *getValues (unsigned int elements)
    11 {
    11 {
    12     double *values;
    12     double *values;
    13     int i;
    13     int i;
    14 
    14 
    15     if ((values = calloc (elements + 1, sizeof (double))) == NULL)
    15     if ((values = calloc (elements + 1, sizeof (double))) == NULL)
    23 
    23 
    24 int main (int argc, char **argv)
    24 int main (int argc, char **argv)
    25 {
    25 {
    26     double *values = getValues (MAX);
    26     double *values = getValues (MAX);
    27 
    27 
    28     int i;
    28     unsigned int i;
    29 
    29 
    30     for (i = 0; i < MAX; i++) {
    30     for (i = 0; i < MAX; i++) {
    31         if (fabs (cos (i) - values[i]) < 0.001)
    31         if (fabs (cos (i) - values[i]) < 0.001)
    32             printf ("COS(%d) = %3.2g = %3.2g\n", i, values[i], cos (i));
    32             printf ("COS(%d) = %3.2g = %3.2g\n", i, values[i], cos (i));
    33     }
    33     }