12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
#include <iostream> #include <cmath> using namespace std; class Coord { friend Coord convPol(double, double); private: double xval; double yval; public: Coord(double = 0, double = 0); void display(); }; Coord::Coord(double x, double y) { xval = x; yval = y; } void Coord::display() { cout << "The x co-ordinate is " << xval << endl; cout << "The y co-ordinate is " << yval << endl; return; } Coord convPol(double r, double theta) { Coord a; a.xval = r * sin(theta); a.yval = r * cos(theta); return a; } int main() { double r = 0; double theta = 0; cout << "This program will convert polar co-ordinates to x and y co-ordinates" << endl; cout << "Enter your values for r and theta" << endl; cin >> r; cin >> theta; Coord a (convPol(r,theta)); cout << "The values for x and y are " << a.display(); return 0; }
void Coord::display()
int add(int x , int y){return x+y;}
cout << "The values for x and y are " << a.display();
12
Coord a (convPol(r,theta)); a.display();