I need some help here. I have to create a project to plot Cartesian graphs. Until now i am using c++ to calculate the Cartesian coordinates, but i need further development. I enter a loop where my x coordinate every time adds 0.1, and the corresponding y coordinate for the given equation is created.
I have an equation :-
and, my code goes as given below. Sample output, of first 6 x and y coordinates is also given (here also i had to type all the values)
But i need to get this information out of c++. Until now, i have to copy all the coordinates one by one. i need a tag which could export this info in another form, like word doc, or spreadsheet(x coordinate and y coordinate as 2 separate columns).
x coordinate = 0
y coordinate = 4.7
x coordinate = 0.1
y coordinate = 4.699765
x coordinate = 0.2
y coordinate = 4.69906
x coordinate = 0.3
y coordinate = 4.697885
x coordinate = 0.4
y coordinate = 4.696238
x coordinate = 0.5
y coordinate = 4.694121
I am not very Good at c++. I did not fully understand ur answer. I need more explained answer.
so, according to you, in my code, i should write like this:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//the values of a and be a are are already inputed by the user in the earlier phase of my code
cout<<"\n\nX coordinate = "<<i;
cout<<"\nY coordinate = "<<e;
ifs << x << "," << y << "\r\n";
Would this create this "coordinates,csv" in its main folder, every time i run the software and it calculates the required result?
And also please tell if any libraries are required to mention
I am asking cause i didnt understand the wiki u have mentioned
Also, you shouldn't use FP numbers in a loop. They are not exact. Instead calculate the number of times the loop needs to run, and convert that to an int. Should be easy (EndValue - StartValue) / StepValue, so for you this (10.0 - 0.0) / 0.1 = 100.0. Use static_cast<int> to do the casting.
So use ints as variable types in the for loop, but double types inside the loop.