Monday, 14 September 2020

A program to find the quadrants of a given co-ordinates.


//program to find the quadrants of the coordinates//

#include<stdio.h>

int main()

{

int x,y;

printf("Enter the co-ordinates:");

scanf("%d %d",&x ,&y);

if(x>0&&y>0)

{

printf("Co-ordinates (%d,%d) lies in 1st quadrant",x,y);

}

if(x<0 y="">0)

{

printf("Co-ordinates (%d,%d) lies in 2nd quadrant",x,y);

}

if(x<0 p="" y="">

{

printf("Co-ordinates (%d,%d) lies in 3rd quadrant",x,y);

}

if(x>0&&y<0 p="">

{

printf("Co-ordinates (%d,%d) lies in 4th quadrant",x,y);

}

if(x=0&&y=0)

{

printf("Co-ordinates(%d,%d) lies in origin",x,y);

}

return 0;

}


OUTPUT:


DESCRIPTION:
At first, we ask the user to input the co-ordinates .We check either the co-ordinates are positive or negative and display the quadrants according to that.And the co-ordinates(0,0) are the origin point.

For example:
(-4,-6)
Here both the x and y co-ordinates are negative.So,the output is 3rd quadrant.

2 comments:

If you have any doubt, please ask in the comment section.

Search This Blog

Program to print weather the number is happy or not.

#include <stdio.h> #include <math.h> int main () { int i , j , num , temp , sum = 0 ; printf ( "Enter number\n...