# C Exercises: Find the quadrant in which the coordinate point lies

## C Conditional Statement: Exercise-9 with Solution

Write a C program to accept a coordinate point in a XY coordinate system and determine in which quadrant the coordinate point lies.
Test Data :
7 9
Expected Output :
The coordinate point (7,9) lies in the First quandrant.

Sample Solution :-

C Code:

```#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);

}
```

Flowchart :

Code Editor :

```#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);

}```

Improve this sample solution and post your code through Disqus.

﻿

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number