Thursday 25 July 2013

Chapter 2 solutions problem[C][l]

Question-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).
Solution- Question is little bit weird for me,but still here is the solution for what i understood.

#include<stdio.h>
int main()
{
int x,y;
printf("Enter any point\n");
scanf("%d%d",&x,&y);
if(x==0&&y!=0)
printf("Point lies on y axis\n");
else if(y==0&&x!=0)
printf("point lies on y axis\n");
else if(y==0&&x==0)
printf("point lies on the origin\n");
else
printf("point lies somewhere in 2-d \n");
return 0;
}
  

No comments:

Post a Comment