"Umesh" <> wrote in message
news: oups.com...
> I've not used graphics.h before. How can I plot a function say
> y=sin(x) ?
>
It's a platform-specific header.
I've no idea how it works, but presumably you will need to intialise a
graphics display. Then there will almost certainly be a function called
something like plotxy(). It may take floats but will probably take integers.
Your x axis will go from -PI to + PI, whilst your y axis will go from -1 to
+1. However to really see the shape of the function, keep the scales the
same, that's why we measure angles in radians.
So all you need to do is maintain a double x, and take pixel steps from -PI
to +PI. Call sin() to get y. Then convert from the mathematical coordinates
to the pixel coordinates, making x = 0, y = 0 the centre pixel of the
display, and call the plot function.
--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm