title: Putting values from an Increment in C++ into Excel
body: <p>I am trying to put my answers gained from this increment; </p>
  
  <pre><code>for(int i=0; i&lt;=n; i++)
    {
    Xnew = -i*(Y+R1)/n; //calculation for angles and output displayed to user
  
    Ynew = pow((((Y+R1)*(Y+R1)) - (Xnew*Xnew)), 0.5);
  
    cout&lt;&lt;"\n("&lt;&lt;Xnew&lt;&lt;", "&lt;&lt;Ynew&lt;&lt;")"&lt;&lt;endl;
  
    AngleB = acos(Xnew/pow((pow(Xnew, 2))+(pow(Ynew, 2)), 0.5))*(180/Pi);
  
    cout&lt;&lt;"\nAngle 'B' = "&lt;&lt;AngleB1&lt;&lt;" Degrees"&lt;&lt;endl;
  
    AngleV = acos(((pow(Xnew, 2))+(pow(Ynew, 2))+(pow(100, 2))-(pow(65, 2)))/(200*(pow(((pow(Xnew, 2))+(pow(Ynew, 2))), 0.5))))* (180/Pi);
  
    cout&lt;&lt;"Angle 'V' = "&lt;&lt;AngleV&lt;&lt;" Degrees"&lt;&lt;endl;
    AngleTheta1 = AngleB - AngleV;
  
    cout&lt;&lt;"Theta 1 = "&lt;&lt;AngleTheta1&lt;&lt;" Degrees"&lt;&lt;endl;
  
    AngleTheta2 =(asin(pow(((sin(AngleV*Pi/180))*(pow(((pow(Xnew, 2))+(pow(Ynew, 2))), 0.5))/65), 0.5)))*(180/Pi);
  
    cout&lt;&lt;"Theta 2 = "&lt;&lt;AngleTheta2&lt;&lt;" Degrees"&lt;&lt;endl;
  
    }
  </code></pre>
  
  <p>Now, depending on what value the user chooses for 'n', then a list of 'n' number of values will appear. E.G. So I will get 2 co-ordinate (Xnew, Ynew), and 4 different angles if n = 2. </p>
  
  <p>Now, we are having trouble inputting these values into Excel, where a table of values with headers would appear. We have tried to write in CSV. format, but we only succeeded in getting Excel to display one value in each column, and not the list of values that we wanted (when n>1).</p>
  
  <p>We were given this code by a postgrad helper for our project which still hasn't really helped.</p>
  
  <pre><code>// writing on a text file
     #include &lt;iostream&gt;
     #include &lt;fstream&gt;
     using namespace std;
  
     int main () {
     ofstream myfile ("h:\\test\\files\\example.txt");
     if (myfile.is_open())
     {
         myfile &lt;&lt; "This is a line.\n";
         myfile &lt;&lt; "This is another line.\n";
         myfile.close();
     }
     else cout &lt;&lt; "Unable to open file";
     return 0;
     }
  </code></pre>
  
  <p>So, does anyone have any suggestions on how to put our calculated values onto Excel, displayed in the format I specified above? Thanks again, hope the question is clear enough. </p>
  
  <p>Here roughly the code we tried before (though we did delete it so may not be perfect) when we got the broken single values to appear. </p>
  
  <p>Under int main(){</p>
  
  <pre><code> std::ofstream file_out("Test.csv");
  </code></pre>
  
  <p>and at the bottom (Underneath all the code)</p>
  
  <pre><code> file_out &lt;&lt; "x, x2, x3" &lt;&lt; std:endl;
   file_out &lt;&lt; x &lt;&lt; ", " &lt;&lt; x2 &lt;&lt; ", " &lt;&lt; x3 &lt;&lt; std::endl;
  </code></pre>
  
  <p>But x, x2, and x3 were all the values specified above (i.e. AngleB, Xnew, etc. )</p>