{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AIQ1 - "<<theta<<endl system"notepad...

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: "<<theta<<endl; } system("notepad xy2polar.out"); return 0; } void polar(float x,float y,float& ptr_r,float& ptr_theta) { ptr_r=sqrt(x*x+y*y); if(ptr_r==0.) ptr_theta=0; else if(ptr_r>0.&&y>0.) ptr_theta=acos(x/ptr_r); else if(ptr_r>0.&&y<=0.) ptr_theta=-acos(x/ptr_r); }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online