AIQ1 -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<fstream> #include<cmath> using namespace std; void polar(float,float,float&,float&); int main(void) { float x, y, r, theta; ifstream fin("xy2polar.in"); ofstream fout("xy2polar.out"); while(fin>>x>>y) { polar(x,y,r,theta); fout<<"The polar coordinates of ("<<x<<","<<y<<") are r = "<<r<<" and theta =
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: &quot;&lt;&lt;theta&lt;&lt;endl; } system(&quot;notepad xy2polar.out&quot;); return 0; } void polar(float x,float y,float&amp; ptr_r,float&amp; ptr_theta) { ptr_r=sqrt(x*x+y*y); if(ptr_r==0.) ptr_theta=0; else if(ptr_r&gt;0.&amp;&amp;y&gt;0.) ptr_theta=acos(x/ptr_r); else if(ptr_r&gt;0.&amp;&amp;y&lt;=0.) ptr_theta=-acos(x/ptr_r); }...
View Full Document

This note was uploaded on 02/21/2010 for the course ENGM 2282 taught by Professor Phillips during the Winter '10 term at Dalhousie.

Ask a homework question - tutors are online