Code:
/*This program produce real numbers,x and y.
The minimum number for x is 1,... and the maximum
number is 14{...decimal places}because C is 15 spaces " "
The minimum number for y is 1,... and the maximum
number is 24 {...decimal places}because L is 25 spaces " "
C=WIDTH
L=HEIGHT
* * * * * * * * * * * * * * * *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* * * * * * * * * * * * * * * *
^
|
(0,0)
*/
#include<stdio.h>
#define WIDTH 15
#define HEIGHT 25
int i;
double my_function(double x);
int main(void)
{
double x_spot,y_spot;
for(i=WIDTH-1;i>0;i--)
{
x_spot=(double)i/WIDTH;
y_spot=my_function(x_spot);
printf("%lf\t%lf\n",x_spot,y_spot);
}
return 0;
}
double my_function(double x)
{
double y;
y=x*x*x+x*x-x+0.2;
if (y>0 && y<HEIGHT)/*only possitive values*/
return y;
}
--------------------------------------------------------------------------------
HOW I CAN PRINT THE GRAPH IN THE BOX?
first i run the secondary programm and i place x y values in a *.txt file
secondly i scanf the values and finally place for each coordinate one spot at the command line
i must convert x and y into integers first (int)x=x_spot*HEIGHT; (int)y=y_spot*WIDTH;
I dont understand how i could print the spot for each cordinate starting from the left down corner of
the rectangle (0,0)