#include #include /* This library contains the cos and sin functions */ /* This program converts polar coordinates of the form (radius, angle) to cartesian (x, y) coordinates. */ main() { float radius, /* distance from origin */ degrees, /* angle (in degrees) */ radians, /* corresponding angle in radians (necessary for C's trig) */ x, /* corresponding x and y coordinates */ y; /* Since this is a fairly complex program, we will include some detailed instructions on what will be input */ cout << "This program converts polar coordinates to Cartesian form\n\n"; /* Prompt for input */ cout << "Enter the radius (the distance from the point to the origin): "; cin >> radius; cout << "Enter the angle (in degrees): "; cin >> degrees; /* Convert angle in degrees to radians by multiplying by (PI/90). This is necessary because the C trig functions are in terms of radians. */ radians = degrees * (3.14159/2) / 90; /* Compute x and y using cos and sin functions. */ x = radius * cos(radians); y = radius * sin(radians); /* Output the Cartesian coordinates in an infomative manner. */ cout << "\nThe corresponding Cartesian coordinates are (" << x << ", " << y << ")\n"; }