PROGRAM TO ADD CO_ORDINATE OF X AND Y USING STRUCTURE



Hello Friends !!!! Today I am going to tell about the simple program of structure in c++.Program to add Two co-ordinate using structure in C++.In this Program we add first co-ordinate of X to the first Co-ordinate of Y and second to second.
So here is Program=>
//Name : Mayank Sharma
//Roll No : 26
//C.S.E(4th Sem)

// Write a Program To Add Co-ordinates //

#include
#include
struct add
{
int x;
int y;
};
void main()
{
clrscr();
add p1,p2,p3;
cout<<"Co-ordinate of p1 is :"<<"\n";
cin>>p1.x>>p1.y;
cout<<"co-ordinate of p2 is :"<<"\n";
cin>>p2.x>>p2.y;
p3.x=p1.x+p2.x;
p3.y=p1.y+p2.y;
cout<<"co-ordinate of X after sum is :"<<"\n"< cout<<"co-ordinate of y after sum is :"<<"\n"< getch();
}

Output of program is :
Co-ordinate of p1 is :
13
14
co-ordinate of p2 is :
20
30
co-ordinate of X after sum is :
33
co-ordinate of y after sum is :
44

I think this post will help you.I think this post will help you.
Thanks!!!
If any query about this post then put your comment in comment box below..

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites