Your question is a little bit too vague to answer as it stands. For example, are you working with a particular GUI framework/API? Or are you wanting to write a console application?
OK, for a console application, I suggest you split the problem up.
- first calculate the required data
- plot it
How may chars can you fit across the console?
=> Use this to work out the increment (of x) which gets you from your starting value to your ending value in that many increments.
How many rows of chars can you display on your console?
=> That will determine your vertical resolution.
Now you know how many value you need, you can populate an array (calculate it).
Then, as you plot/draw each stripe, you can test to see if the y value is within the range for a box. If so, draw a char of some kind. Otherwise a blank.
You will also need to think about how to draw the axis.
thanks for the help you gave but i was just wondering is there another way to make a graph?
I've googled around a bit and have seem bits of code and heard of a library called graphs.
Is there some simple code to made a curved line graph?
If you're using Microsoft Visual C++ Professional (or better), you'll have the MFC classes. They're very easy for drawing. I'm not sure if they can handle mathematical functions as input, but I imagine so.
Have you been any guidance about what libraries to use? I have no idea of what you already know, or what's expected of you.
It's not esp. difficult to draw a graph using WIN32 or MFC, or another GIU toolkit, but if you've never coded a GUI app before you've got a little bit of learning to do before it's easy.