/*
Declare a struct called Point with two members x and y (both of type 
float; this is representing a point in the Cartesian plane). Then write 
a function called read_point to read a Point from the 
keyboard and return it. Also, write a function called print_point with 
a parameter of type Point to print its Point argument. Finally, write a 
function called add_points to add two points and return that 
(remember (x1,y1)+(x2,y2)=(x1+x2,y1+y2)). The function should have two 
parameters of type Point (these are the ones that are to be added up).
*/

#include <iostream>
using namespace std;
struct Point
{
	float x, y;
};
void read_point(Point& p);
void print_point(Point);
Point read_point();
Point add_points(Point p1, Point p2);
int main()
{
	Point p1, p2, p3;
	// read_point(p1); // OK
	p1 = read_point();
	p2 = read_point();
	//p3 = p1 + p2; // ERROR
	p3 = add_points(p1,p2);
	print_point(p3);
	cout << endl;
	return 0;
}
void read_point(Point& p)
{
	cout << "Enter two real numbers (x-coordinate and 
y-coordinate):\n";
	cin >> p.x >> p.y;
}

Point read_point()
{
	Point p;
	cout << "Enter two real numbers (x-coordinate and 
y-coordinate):\n";
	cin >> p.x >> p.y;
	return p;
}

void print_point(Point p)
{
	cout << "(" << p.x << "," << p.y << ")";
}
Point add_points(Point p1, Point p2)
{
	Point p3;
	p3.x = p1.x + p2.x;
	p3.y = p1.y + p2.y;
	return p3;
}

