Answer to Question #50073 in C++ for umer inayat

Question #50073
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
vertical axis, and 5 units up from the horizontal 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 two
points, and whose y coordinate is the sum of the 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. 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 p1+p2 are: 8, 11
1
Expert's answer
2014-12-23T01:05:06-0500
#include <iostream>
using namespace std;

struct point
{
intx;
inty;
};

int main( )
{
point A,B,C;
cout<<"Enter coordinates for p1:";
cin>>A.x>>A.y;
cout<<"Enter coordinates for p2:";
cin>>B.x>>B.y;

C.x=A.x+B.x;
C.y=A.y+B.y;

cout<<"Coordinates of p1+p2 are:"<<C.x<<", "<<C.y;

return 0;
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

mateen naeem
09.04.23, 07:42

it is really good this website is incredible and it can also solve my issues

Assignment Expert
24.09.18, 20:15

Dear ANurag, please submit new question with all requirements.

ANurag
24.09.18, 19:59

Solve Same problem using class

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS