Friday 23 January 2015

A point on the 2-d can be represented by two numbers: an x co-ordinate and a y co- ordinate. For example (4,5) represents a point 4 units to the right of origin and 5 units up the origin. The sum of two points can be defined as a new point whose x co- ordinate is the sum of x co-ordinates of both points and same for y co-ordinates. Write a C++ 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.


#include<iostream>
using namespace std;
struct point
{
int x,y;
};
int 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<<"p3's x coordinate is " < cout<<"p3'y coordinate is " < return 0;
}

2 comments:

  1. output of this prgm in user screen

    ReplyDelete
  2. NJ Sports Betting - DRMCD
    With the launch 전라남도 출장마사지 of the 2021 mobile sports betting 안양 출장마사지 market, bet365 is 서울특별 출장안마 offering legal sports betting, 시흥 출장마사지 including 경산 출장샵 the addition of more than NY Sportsbook Bonus

    ReplyDelete

SAY HELLO!!