C Program to Determine the Quadrant of the Cartesian Plane

Let’s have a look at how to determine the Quadrant of the Cartesian Plane. This C Program read the x and y coordinates of the vertex and also read a Length of aside.

C Program to Determine the Quadrant of the Cartesian Plane

#include <stdio.h>
void main()
{
	int co1,co2;
	printf("Input the values for X and Y coordinate : ");
	scanf("%d %d",&co1,&co2);

	if( co1 > 0 && co2 > 0)
	  printf("The coordinate point (%d,%d) lies in the First quandrant.\n",co1,co2);
	else if( co1 < 0 && co2 > 0)
	  printf("The coordinate point (%d,%d) lies in the Second quandrant.\n",co1,co2);
	else if( co1 < 0 && co2 < 0)
	  printf("The coordinate point (%d, %d) lies in the Third quandrant.\n",co1,co2);
	else if( co1 > 0 && co2 < 0)
	  printf("The coordinate point (%d,%d) lies in the Fourth quandrant.\n",co1,co2);
	else if( co1 == 0 && co2 == 0)
	  printf("The coordinate point (%d,%d) lies at the origin.\n",co1,co2);

}

Output:

Input the values for X and Y coordinate : 7 9                                                                 
The coordinate point (7,9) lies in the First quandrant.

Leave a Comment

Your email address will not be published. Required fields are marked *