#include	"stdio.h"
#include	"math.h"

#define	FALSE	0
#define	TRUE	!FALSE

double	max,min,k;

double f(double x)
	{
	return sin(3 * x);
	}

int	v(double y)
	{
    	return (int)( (y - min) * k );
    	}

main()
	{
	double	a,b,h,x,y;
	int		i,vy;
    FILE	*fp;

	a = -10.0;
	b = 10.0;
	h = .1;

	min = f(a);
    	max = f(a);
	for (x = a; x <= b; x = x + h)
		{
		y = f(x);
		if (y < min)
			min = y;
		if (y > max)
			max = y;
		}
    	k = 40.0 / (max - min);

	fp = fopen("output.dat","w");

	for (x = a; x <= b; x = x + h)
		{
		vy = v(f(x));
		for (i = 0; i < vy; i++)
   	    		{
			fprintf(fp," ");
			printf(" ");
			}
		fprintf(fp,"*\n");
		printf("*\n");
		}

	fclose(fp);
	}

