// 9_1.cpp: defines the entry point of the console application.
//
// Define the coodin header file
# Ifndef coordin_h _
# Define coordin_h _
Struct polar
{
Double distance;
Double angle;
};
Struct rect
{
Double X;
Double Y;
};
Polar rect_to_polar (rect xypos );
Void show_polar (polar dapos );
# Endif
9_1_2 File
# Include "stdafx. H"
# Include <iostream>
# Include <cmath>
# Include "coordin. H"
Polar rect_to_polar (rect xypos)
{
Using namespace STD;
Polar answer;
Answer. Distance = SQRT (xypos. x * xypos. x + xypos. y * xypos. y );
Answer. angle = atan2 (xypos. Y, xypos. X );
Return answer;
}
Void show_polar (polar dapos)
{
Using namespace STD;
Const double red_to_deg = 57.29577951;
Cout <"distance =" <dapos. distance;
Cout <", angle =" <dapos. Angle * red_to_deg;
Cout <"Degrees \ n ";
}
9_1 File
// 9_1.cpp: defines the entry point of the console application.
//
# Include "stdafx. H"
# Include <iostream>
# Include "coordin. H"
Using namespace STD;
Int _ tmain (INT argc, _ tchar * argv [])
{
Return 0;
}
Int main ()
{
Rect rplace;
Polar pplace;
Cout <"Enter the X and Y value :";
While (CIN> rplace. x> rplace. Y)
{
Pplace = rect_to_polar (rplace );
Show_polar (pplace );
Cout <"next two numbers (Q to quit ):";
}
Cout <"Bye! \ N ";
Return 0;
}