C program to accept a coordinate point in a XY coordinate system and determine its quadrant

by Nideesh C on April 13, 2011 · 0 comments

in C Programming




/* 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 quadrant\n”);
else if( x < 0 && y > 0)
printf(“point (%d,%d) lies in the Second quadrant\n”);
else if( x < 0 && y < 0)
printf(“point (%d, %d) lies in the Third quadrant\n”);
else if( x > 0 && y < 0)
printf(“point (%d,%d) lies in the Fourth quadrant\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 quadrant

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

———————————————*/

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program (1-D Array) store some elements in it.Accept key & split from that point. Add the first half to the end of second half
  2. C program to accept two integers and check if they are equal
  3. C program to accept an array of integers and delete the specified integer from the list
  4. C Program to accept two matrices and check if they are equal
  5. C program to accept the height of a person in centimeter and categorize the person based on height as taller, dwarf and average height person

Leave a Comment

Previous post:

Next post: