-
Language
C
-
Description
The conditions for a given point to be lies on the x-axis and y-axis or on the origin are:
a) For origin; x is equal to 0 and y is equal to 0.
b) For y-axis; x is equal to 0 and y is not equal to 0.
c) For x-axis; x is not equal to 0 and y is equal to 0.
Write an algorithm to find out if given point (x, y) lies on the x-axis, y-axis or on the origin.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
float x, y;
printf ("Enter the value of x: ");
scanf ("%f", &x);
(void) getchar ();
printf ("Enter the value of y: ");
scanf ("%f", &y);
(void) getchar ();
if(x==0&&y==0)
printf ("Origin\n");
if(x==0&&y!=0)
printf ("Y-axis\n");
if(x!=0&&y==0)
printf ("X-axis\n");
if(x>0&&y>0)
printf ("Quadrant I\n");
if(x<0&&y>0)
printf ("Quadrant II\n");
if(x<0&&y<0)
printf ("Quadrant III\n");
if(x>0&&y<0)
printf ("Quadrant IV\n");
putchar ('\n');
system ("pause");
return EXIT_SUCCESS;
}
#include <stdlib.h>
int main (void)
{
float x, y;
printf ("Enter the value of x: ");
scanf ("%f", &x);
(void) getchar ();
printf ("Enter the value of y: ");
scanf ("%f", &y);
(void) getchar ();
if(x==0&&y==0)
printf ("Origin\n");
if(x==0&&y!=0)
printf ("Y-axis\n");
if(x!=0&&y==0)
printf ("X-axis\n");
if(x>0&&y>0)
printf ("Quadrant I\n");
if(x<0&&y>0)
printf ("Quadrant II\n");
if(x<0&&y<0)
printf ("Quadrant III\n");
if(x>0&&y<0)
printf ("Quadrant IV\n");
putchar ('\n');
system ("pause");
return EXIT_SUCCESS;
}