0% found this document useful (0 votes)
185 views1 page

Write A C Program To Accept A Coordinate Point

This C program accepts x and y coordinate values from the user, determines which quadrant the coordinate point falls in based on the signs of x and y, and prints the corresponding quadrant. It handles points in the first, second, third and fourth quadrants as well as the origin point at x=0, y=0.

Uploaded by

sangitsme
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views1 page

Write A C Program To Accept A Coordinate Point

This C program accepts x and y coordinate values from the user, determines which quadrant the coordinate point falls in based on the signs of x and y, and prints the corresponding quadrant. It handles points in the first, second, third and fourth quadrants as well as the origin point at x=0, y=0.

Uploaded by

sangitsme
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/* Write a 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");

} /* End of main() */

/*---------------------------------------------
Output
RUN 1
Enter the values for X and Y
3 5
point (5,3) lies in the First quandrant

RUN 2
Enter the values for X and Y
-4
-7
point (-7, -4) lies in the Third quandrant

---------------------------------------------*/

You might also like