Answer to Question #241958 in C for Kelly

Question #241958
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


Please it's urgent
1
Expert's answer
2021-09-25T03:03:26-0400
#include <stdio.h>




int main(){
	int x;
	int y;
	printf("Enter the x-y coordinate of a point in a Cartesian plane: ");
	scanf("%d%d", &x,&y);
	if (x == 0 && y == 0){
		printf("(%d,%d) is the origin",x,y);
	}else if (y == 0){
		printf("(%d,%d) is on the x-axis",x,y);
	}else if (x == 0){
		printf("(%d,%d) is on the y-axis",x,y);
	}else if (y > 0){
		if (x > 0){
			printf("(%d,%d) is in the first quadrant",x,y);
		}else{
			printf("(%d,%d) is in the second quadrant",x,y);
		}
	}else{
		if (x < 0){
			printf("(%d,%d) is in the third quadrant",x,y);
		}else{
			printf("(%d,%d) is in the fourth quadrant",x,y);
		}
	}
	scanf("%d", &x);
	return 0;
}

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