Saturday, January 30, 2010

CHAP 2[C]L Checking if coordinate lies on,x,y axis or on origin

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).

void main()
{
float x,y;
printf("\nInput the(x,y) values");
scanf("%f%f",&x,&y);
if(x==0&&y==0)
printf("\nThe point lies on the origin");
else if(x==0&&y!=0)
printf("\nThe point lies on the y-axis");
else if(x!=0&&y==0)
printf("\nThe point lies on the x-axis");
else
printf("\nThe point does not lie on any axis or origin");
}

No comments:

Post a Comment