Answer to Question #156655 in C++ for Raihan Afryna binti Raizam

Question #156655

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-axis or y-axis, or appears in particular quadrant (1st quadrant, 2nd quadrant, 3rd quadrant

or 4th quadrant).


1
Expert's answer
2021-01-19T12:34:51-0500
#include<iostream>
using namespace std;
int main(){
int x,y;
cout<<"Enter x and y co ordinates respectly"<<endl;
cin>>x>>y;
if((x>0) && (y>0)){cout<<"first quadrant"<<endl;}

if((x<0) && (y>0)){cout<<"second quadrant"<<endl;}

if((x<0) && (y<0)){cout<<"second third"<<endl;}
if((x>0) && (y<0)){cout<<"second fourth"<<endl;}

if((x==0) && (y==0)){cout<<" origin"<<endl;}

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