Function-defined string.

Lets say I have a function that isolates the y and has x values, like y = 2x + 1 or y = x^2.
I want to make a code that would give me a string of the values like this for whatever number of values I want:

"[x,y],[x2,y2],[x3,y3],[x4,y4],[x5,y5],[x6,y6],[x7,y7].......,[x(n-1),y(n-1)],[x(n),y(n)]"

How would I do that?
Maybe something like the following would be fitting to your needs?:

1
2
3
4
5
6
7
8
9
string function(range start, range end)
{
from start to end:
{
calculate y using x;
string << [x,y],;
}
return string;
}

(pseudo code of course)...
Can you write the actual code with a simple formula like y =x? Also, how would I save it to a text file?
Last edited on
Also, how would I save it to a text file?


http://cplusplus.com/doc/tutorial/files/
Thanks for that Archaic.
Topic archived. No new replies allowed.