**A point on the two dimensional plane can be represented by two numbers: an X coordinate and a Y coordinate. For example, (4,5) represents a point 4 units to the right of the origin along the X axis and 5 units up the Y axis. The sum of two points can be defined as a new point whose X coordinate is the sum of the X coordinates of the point and whose Y coordinate is the sum of their Y coordinates. Write a program that uses a structure called point to model a point. Define three points, and have the user input values to two of them. Than 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 P1 + P2 are : 8, 11**

**Implementation of the above problem:***#include<iostream.h>*

*#include<conio.h>*

*#define N 2*

*struct point*

*{*

*int x;*

*int y;*

*}*

*p[N],pt={0,0};*

*int main()*

*{*

*int i;*

*clrscr();*

*for(i=0;i<=N-1;i++)*

*{*

*cout<<"enter coordinates x"<<i+1<<" & y"<<i+1<<":";*

*cin>>p[i].x>>p[i].y;*

*}*

*for(i=0;i<=N-1;i++)*

*{*

*pt.x=pt.x+p[i].x;*

*pt.y=pt.y+p[i].y;*

*}*

*cout<<"sum of "<<N<<" points is:"<<pt.x<<","<<pt.y;*

*getch();*

*return 0;*

*}*

**Thanks**

**Mukesh Rajput**
## Post A Comment:

## 0 comments: