// Example of passing arguments by reference
// The Cartesian coordinates (x, y, z) of a point are
// obtain from the spherical coordinates (r, theta, phi).
// Note that only x, y, and z are passed by reference.
#include <iostream>
#include <cmath>
using namespace std;

void getCartesianCoordinates(
double, double, double, double&, double&, double&);

int main() {

  double r, theta, phi;
  cout << "Input coordinates  r, theta, and phi: ";
  cin >> r >> theta >> phi;

  double x, y, z;
  getCartesianCoordinates(r, theta, phi, x, y, z);
  cout << x << " " << y << " " << z << endl;

}

void getCartesianCoordinates(
double r, double t, double p, double& a, double& b, double& c)
{
  a = r*sin(t)*cos(p);
  b = r*sin(t)*sin(p);
  c = r*cos(t);
}
