Answer to Question #238701 in C for Woyengimiesindo Ma

Question #238701
Write a program that prompts the user to input the x-y coordinate of a point in a Cartesian plane. The
program should then output a message indicating whether the point is the origin, is located on the x-
(or y-) axis, or appears in a particular quadrant. For example:
(0, 0) is the origin
(4, 0) is on the x-axis
(0, -3) is on the y-axis
(-2, 3) is in the second quadrant
1
Expert's answer
2021-09-17T17:08:14-0400
#include<stdio.h>
int main(){
	int x, y;
	printf("Enter x-coordinate:\n");
	scanf("%d", &x);
	printf("Enter y-coordinate:\n");
	scanf("%d", &y);
	if(x==0 && y== 0){
		printf("(%d, %d) is the origin", x,y);
	}
	else if(x != 0 && y==0){
		printf("(%d, %d) is on the x-axis", x,y);
	}
	else if(x == 0 && y !=0){
		printf("(%d, %d) is on the y-axis", x,y);
	}
	else if(x > 0 && y>0){
		printf("(%d, %d) is in the first quadrant", x,y);
	}
	else if(x < 0 && y>0){
		printf("(%d, %d) is in the second quadrant", x,y);
	}
	else if(x > 0 && y<0){
		printf("(%d, %d) is in the fourth quadrant", x,y);
	}
	else if(x < 0 && y<0){
		printf("(%d, %d) is in the third  quadrant", x,y);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS