This C Program read a coordinate point in a XY coordinate system and determine its quadrant. The program accepts X and Y. Depending on the value of X and Y we need to determine on which quadrant this point lies.

Here is source code of the C program to read a coordinate point in a XY coordinate system and determine its quadrant. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

`/*`

`* C program to accept a coordinate point in a XY coordinate system`

`* and determine its quadrant`

`*/`

`#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 quandrant\n");

else if (x < 0 && y > 0)

printf("point (%d, %d) lies in the Second quandrant\n");

else if (x < 0 && y < 0)

printf("point (%d, %d) lies in the Third quandrant\n");

else if (x > 0 && y < 0)

printf("point (%d, %d) lies in the Fourth quandrant\n");

else if (x == 0 && y == 0)

printf("point (%d, %d) lies at the origin\n");

`}`

advertisement

$ cc pgm76.c $ a.out Enter the values for X and Y 20 30 point (-1079549476, -1079549480) lies in the First quandrant $ a.out Enter the values for X and Y -30 -60 point (-1080802740, -1080802744) lies in the Third quandrant $ a.out Enter the values for X and Y 300 -8 point (-1078902004, -1078902008) lies in the Fourth quandrant $ a.out Enter the values for X and Y -180 180 point (-1076456724, -1076456728) lies in the Second quandrant

**Sanfoundry Global Education & Learning Series – 1000 C Programs.**

advertisement

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.