Question

Write a program that takes the x, y coordinates of a point in the Cartesian plane...

Write a program that takes the x, y coordinates of a point in the Cartesian plane and prints a message telling either which axis the point lies on or the quadrant in which it is found.

image?w=197&h=186&rev=74&ac=1

Sample Output

(-1.0, -2.5) is in quadrant 3

(0.0, -4.8) is on the y-axis

IN C CODE PLEASE! (NOT C++)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>
#include <math.h>

struct Point     //structure
{
   float x;
   float y;
};


   int quadrant(struct Point p) //quadrant function to determine the quadrant in which point lies
   {
       if( p.x>0 && p.y>0)
       return 1;
       else if(p.x<0 && p.y>0)
       return 2;
       else if(p.x<0 && p.y<0)
       return 3;
       else if(p.x>0 && p.y<0)
       return 4;
       else
       return 0;
    
   }

int axis(struct Point p) //axis function to determine on which axis point lies
{
if(p.x == 0)
return 1;
else if(p.y == 0)
return 2;
else
return 0;

}

   int main()
   {
       struct Point p1 = {-1.0, -2.5};
       struct Point p2 = {0.0, -4.8};
     
       printf("(%.1f,%.1f) is in quadrant %d",p1.x,p1.y,quadrant(p1));
     
       printf("\n");
       if(axis(p2) == 1)
       printf("%.1f,%.1f is on y axis",p2.x,p2.y,axis(p2));
       else if(axis(p2) == 2)
       printf("%.1f,%.1f is on x axis",p2.x,p2.y,axis(p2));
     
       else
       printf("\n");
     
      return 0;
   }


Output:

(-1.0, -2.5) is in quadrant 3

(0.0, -4.8) is on the y-axis

Add a comment
Know the answer?
Add Answer to:
Write a program that takes the x, y coordinates of a point in the Cartesian plane...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a Java application that prompts the user to input the x- and y-coordinates of a...

    Design a Java application that prompts the user to input the x- and y-coordinates of a point in a Cartesian plane. The program then should output a message indicating whether the point is the origin, or 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 The numbering of the...

  • the cartensian coordinates of a point in the xy plane are (-4.6, -4.2). find the polar...

    the cartensian coordinates of a point in the xy plane are (-4.6, -4.2). find the polar coordinates of the point. O "Use 8-tan Katarina is correct. Note that Dacia must use the signs of x and y to find on which quadrant the point lies. Part 9 of 10 - Analyze The friends are ready to try a few problems. The Cartesian coordinates of a point in the xy plane are (-4.6, -4.2). Find the polar coordinates of the point....

  • The Cartesian coordinates of a point in the xy plane are (x, y) = (3,5) m....

    The Cartesian coordinates of a point in the xy plane are (x, y) = (3,5) m. The polar coordinates of this point are (5.83, 59°). Select one: O True O False

  • (a) The Cartesian coordinates of a point in the xy-plane are (x, y) = (-3.44, -2.64)...

    (a) The Cartesian coordinates of a point in the xy-plane are (x, y) = (-3.44, -2.64) m. Find the polar coordinates of this point. r = m θ = ° (b) Convert (r, θ) = (4.73 m, 36.1°) to rectangular coordinates. x = m y = m

  • The Cartesian coordinates of a point in the xy-plane are (x, y) = (-3.27, -2.33) m....

    The Cartesian coordinates of a point in the xy-plane are (x, y) = (-3.27, -2.33) m. Find the polar coordinates of this point. r = _____m θ = ______° (b) Convert (r, θ) = (4.62 m, 38.6°) to rectangular coordinates. x = ____m y = ____m EXERCISE HINTS:  GETTING STARTED  |  I'M STUCK! (a) Find the polar coordinates corresponding to (x, y) = (3.12, 1.47) m. r = _____m θ = _____° (b) Find the Cartesian coordinates corresponding to (r, θ) = (4.22...

  • The cartesian coordinates of a point in the xy plane are (x,y) = (-3.50,-2.50)m as shown...

    The cartesian coordinates of a point in the xy plane are (x,y) = (-3.50,-2.50)m as shown in figure. Find polar coordinates of this point.

  • Using C# Exercise #3: Design and implement a program (name it CheckPoint) that prompts the user...

    Using C# Exercise #3: Design and implement a program (name it CheckPoint) that prompts the user to enter the x-coordinate then y-coordinate of a point (in a Cartesian plane) as integer values. The program prints out the entered values followed by the location of the point on the plane. The possibilities for a point are: the origin point, on the x-axis, on the y-axis, in the first quadrant, in the second quadrant, in the third quadrant, or in the fourth...

  • PLEASE DO IN PSEUDOCODE; Design and implement a program (name it CheckPoint) that prompts the user...

    PLEASE DO IN PSEUDOCODE; Design and implement a program (name it CheckPoint) that prompts the user to enter the x-coordinate then y-coordinate of a point (in a Cartesian plane) as integer values. The program prints out the entered values followed by the location of the point on the plane. The possibilities for a point are: the origin point, on the x-axis, on the y-axis, in the first quadrant, in the second quadrant, in the third quadrant, or in the fourth...

  • Language : C Im more trying to understand this, an example would help which is why...

    Language : C Im more trying to understand this, an example would help which is why i'm posting this question Write script that after coordinates are inputted, prints quadrant or line that the point is on. Should have function that returns a character indicating the quadrant or the line. Probable Return values: X (X-axis) Y (Y-axis) 1 (1st quadrant) 2 (2nd quadrant) 3 (3rd quadrant) 4 (4th quadrant) The printing of the quadrant should be handled inside the main function....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT