Tuesday, 24 December 2013

Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or at the origin, viz. (0, 0).


 #include<iostream>
 using namespace std;
 #include<conio.h>
 int main()
{
  int x_ax,y_ax;

  cout<<"Enter a point (x,y) =   ";
  cin>>x_ax>>y_ax;
  if(x_ax==0&&y_ax!=0)
  {
    cout<<"point is on y axis.........";
  }
  else if(y_ax==0&&x_ax!=0)
  {
    cout<<"The point lies on x axis.";
  }
  else if(x_ax==0&&y_ax==0)
  {
    cout<<"The point lies on origin.";
  }
  getch();
  return 0;
}

No comments:

Post a Comment