C program to accept x and y coordinate of a point and find the quadrant in which the point lies - IProgramX

Q. Accept the x and y coordinate of a point and find the quadrant in which the point lies 




Program

#include<stdio.h>
void main()
{
    int x, y;

    printf("Enter the values for X and Y\n");
    scanf("%d %d", &x, &y);
    if (x > 0 && y > 0)
        printf("point (%d, %d) lies in the First quadrant\n",x,y);
    else if (x < 0 && y > 0)
        printf("point (%d, %d) lies in the Second quadrant\n",x,y);
    else if (x < 0 && y < 0)
        printf("point (%d, %d) lies in the Third quadrant\n",x,y);
    else if (x > 0 && y < 0)
        printf("point (%d, %d) lies in the Fourth quadrant\n",x,y);
    else if (x == 0 && y == 0)
        printf("point (%d, %d) lies at the origin\n",x,y);
}

Output:

Enter the values for X and Y
4 -7
point (4, -7) lies in the Fourth quadrant

Post a Comment

0 Comments