Q12 Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or on the origin, viz. (0,0).

Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or on the origin, viz. (0,0).

Program: 80

Given a point (x, y), write a c program to find out if it lies on the x-axis, y-axis or on the origin, viz. (0,0).

#include<stdio.h>
#include<conio.h>
int main()
{
    int x1, y1;
    printf("Enter the co-ordinates of point: ");
    scanf("%d %d", &x1, &y1);

    if(x1 == 0 && y1 !=0)
        printf("Point (%d, %d) lies on y-axis", x1, y1);
    else if (x1 !=0 && y1 == 0)
        printf("Point (%d, %d) lies on x-axis", x1, y1);
    else if (x1 == 0 && y1 == 0)
        printf("Point (%d, %d) lies on the origin", x1, y1);
    else
        printf("Point (%d, %d) neither lie on x-axis nor on y-axis", x1, y1);
    return 0;
}

Output:

 Enter the co-ordinates of point: 0 5
 Point (0, 5) lies on y-axis

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.