// 10312009b.cpp, P H Anderson, Oct 31, '09

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define NUM_POINTS 300

void more(void);
float *get_floats(int *p_num);

int main()
{
   float x, y, *p;
   int num_floats;
#ifdef FIRST_PART   
   for (int n=0; n<=NUM_POINTS; n++)
   {
        x = 0.0 + M_PI * n / NUM_POINTS;
        y = exp(-x) * cos(5*x);
        printf("%d %.2f %.2f\n", n, x, y);
        more();
   }   
   system("pause");
#endif   
   p = get_floats(&num_floats); 
   
   for (int n=0; n<num_floats; n++)
   { // print the floats
        printf("%d %.1f\n", n, p[n]);
        more();
   }
   system("pause");
}   

float *get_floats(int *p_num)
{    
    float *array, val;
    
    array = (float *) calloc(30, sizeof(float));
    
    for(int n=0; n<30; n++)
    {
        printf("Enter:  ");
        scanf("%f", &val);
        if (val >= 0)
        {
            array[n] = val;
        }
        else
        {
            *p_num = n;
            break;
        }
    }
    return(array);
}
        
void more(void)
{
    static int n=0;
    if(n==25)
    {
        printf("\ntype space to continue.\n");
        while(getchar()!= ' ')
        {
        }
        n=0;
    }
    else
    {
        ++n;
    }
}