Tuesday, 28 March 2017

Here I am giving the solutions for the previous questions , 
Sorry that forgot to give the sample for the output for the previous program.

here's the answer(Code)




#include<iostream.h>
#include<conio.h>
static int count;
class point
{
float a,b;
public:
point()
{
a=b=0;
}
void get()
{   count++;
cout<<"Enter the X coordinate of point "<<count<<"\t";
   cin>>a;
   cout<<"Enter the Y coordinate of point "<<count<<"\t";
   cin>>b;
   }
 void add(point obj1,point obj2)
 {
  this->a=obj1.a+obj2.a;
  this->b = obj1.b+obj2.b;
   }
   void show()
   {
   cout<<"The X coordinate of final point is \t"<<a;
   cout<<"\nthe Y coordinate of final point is\t"<<b;
   }
   };
   void main ()
   {
   point obj1,obj2,obj3;
   obj1.get();
   cout<<"\n\n";
   obj2.get();
   obj3.add(obj1,obj2);
   cout<<"\n\n";
   obj3.show();
   getch();
   }

Sample output: