A point on the two-dimensional plane can be represented by two numbers: an x coordinate and a y coordinate. For example, formula (4, 5) represents a point having abscissa equal to 4 units and ordinate equal to 5 units. The sum of two points can be defined as a new point whose x coordinate is the sum of the x coordinates of the two points, and whose y coordi-nate is the sum of the y coordinates.
Write a program that uses a structure called point to model a point. Define two points, and have the user input values to two of them. Then set the third point equal to the sum of the other two, and display the value of the new point. Interaction with the program might look like this:
Enter coordinates for p1: 3 4
Enter coordinates for p2: 5 7
Coordinates of pl+p2 are: 8, 11
#include<iostream.h>
#include<conio.h>
struct point
{
int x,y;
};
void main()
{
point p1,p2,p3;
cout<<"Enter coordinates for P1: ";
cin>>p1.x>>p1.y;
cout<<"Enter coordinates for P2: ";
cin>>p2.x>>p2.y;
p3.x=p1.x+p2.x;
p3.y=p1.y+p2.y;
cout<<"Coordinates of P1 + P2 are: "<<p3.x<<" "<<p3.y;
getch();
}