http://www.sci.brooklyn.cuny.edu/~sd.../Program6.html

the link above are specifications to making a so called "simple" program, but how would this be done? especially the graphing of sin, cos and tan?

Printable View

- 12-12-2005BroknGraphing a sine/cosine/tan curves in C???
http://www.sci.brooklyn.cuny.edu/~sd.../Program6.html

the link above are specifications to making a so called "simple" program, but how would this be done? especially the graphing of sin, cos and tan? - 12-12-2005hk_mp5kpdwQuote:

graph(sin,0.0,10.0,20);

Code:`void graph( double (*func)(double),double lo,double hi, int number )`

{

double pt;

double inc = (hi-lo)/number;

for( pt = lo; lo <= hi; pt += inc )

{

/* Call the function for the given pt value,**you**would need to

do something with the return value, i.e. store it in an array perhaps

for later use */

func(pt);

}

}

- 12-12-2005Brokn
how would you print an asterisk based on the height?

- 12-13-2005treenef
probably create a 2d char array:-

Code:`[ ][ ][ ][ ][ ][ ][ ]`

[ ][ ][ ][ ][ ][ ][ ]

[ ][ ][ ][ ][ ][ ][ ]

[ ][ ][ ][ ][ ][ ][ ]

[ ][ ][ ][*][ ][ ][ ]

[ ][*][*][ ][*][*][ ]

[ ][*][ ][ ][ ][*][ ]

How you gets the stars into the array will be of course your main problem.