C program to find the Quadrant in which the given coordinates lie - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Thursday, January 9, 2020

C program to find the Quadrant in which the given coordinates lie - My CS Tutorial

In this tutorial we will learn how to write a c program to find the Quadrant in which given coordinates (x,y) lie.
This c program accept x and y coordinate and find the Quadrant.
In the first we will enter the coordinates (x,y) then this program find the Quadrant like as FIRST QUADRANT, SECOND QUADRANT, THIRD QUADRANT AND FOURTH QUADRANT.

C program code


#include<stdio.h>
#include<conio.h>
void main()
{
float x,y;
clrscr();

printf("\n Enter the value of (x,y) Co-Ordinates:\n");
scanf("%f %f",&x,&y);

if(x>0&&y>0)
{
 printf("\n Co-Ordianates (%f,%f) lies in First Quadrant.\n",x,y);
}

if(x<0&&y>0)
{
 printf("\n Co-Ordianates (%f,%f) lies in Second Quadrant.\n",x,y);
}

if(x<0&&y<0)
{
 printf("\n Co-Ordianates (%f,%f) lies in Third Quadrant.\n",x,y);
}

if(x>0&&y<0)
{
 printf("\n Co-Ordianates (%f,%f) lies in Fourth Quadrant.\n",x,y);
}

if(x==0&&y==0)
{
 printf("\n Co-Ordianates (%f,%f) lies at the Origin.\n",x,y);
}

getch();
}


OUTPUT:




In this output we can see, we can find the Quadrant in which the given coordinates lie.
In the first we will enter the coordinates as (x,y).
In this output x is -4.6 and y is -7.8
Both are in negative form
So the Quadrant in which these coordinates are lie  is Third Quadrant.


Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

No comments:

Post a Comment