We're supposed to write a function that calculates both the x and y coordinates of the upper left corner of the square that just contains a circle, given the x and y coordinates of the center of the circle, and the radius of the circle. Return the x and y coordinates of the upper left corner of the square to the calling function.
I have the function write, but I don't know how to just return the value from the function without outputting anything. Please help. Here's my code:
- int circle_x,circle_y,circle_radius,square_x,square_y;
- int x_y_square_coordinates (int circle_x, int circle_y, int circle_radius, int& square_x, int& square_y)
- {
- square_x = circle_x-circle_radius;
- square_y = circle_y-circle_radius;
- return square_x, square_y;
- }
- int main()
- {
- cout << "Enter the x and y coordinates of the center of the circle and the radius of the circle." << endl;
- cout << "x:";
- cin >> circle_x;
- cout << "y:";
- cin >> circle_y;
- cout << "radius:";
- cin >> circle_radius;
- cout << x_y_square_coordinates (circle_x,circle_y,circle_radius,square_x,square_y);
- cin.get();
- getchar();
- return 0;
- }