# C: Enter coordinate and get out a quadrant

This is a discussion on C: Enter coordinate and get out a quadrant within the C Programming forums, part of the General Programming Boards category; The task is to create a c source code program that will name a quadrant when a given coordinate is ...

1. ## C: Enter coordinate and get out a quadrant

The task is to create a c source code program that will name a quadrant when a given coordinate is given.
Example:
Input Coordinate Pair: 0 5.3
Positive y Axis

I need help on how to start this. I know I have to use if else statements but I'm not sure how to work those. I was wondering if someone could help me start off? Thanks.

2. So how do you, yourself, know that (0,5.3) is on the positive y-axis? What is true about all the points on the positive y-axis?

Ditto for all the quadrants: what has to be true about (x,y) for the point to be in (say) quadrant III?

3. Alright, so this is what I came up with so far.

But I'm getting an error:invalid lvalue in assignment on line 20 and 22. Am I doing the else if statements wrong?

Code:
```/* Directives */

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

int main(void)

{

int x, y;

printf("Enter coordinate pair: ");
scanf("%d %d", &x, &y);
if (x = 0 && y > 0)
printf("Positive y Axis");
else if (x > 0 && y = 0)
printf("Positive x Axis");
else if (x < 0 && y = 0)
printf("Negative x Axis");
else if (x = 0 && y < 0)
printf("Negative y Axis");

/* End Program */
return(0);
}```

4. There's a difference between = and ==.

5. Oh! Missed that definition. Thanks!

6. Wait, even though I'm getting the right answers from the program, the grader program is telling me it's not 100% correct. Is there a way I could rewrite the if statements to have the "if else" statements? I'm thinking it's looking for the "if else" statements.

7. Is the grader program looking at your source code, or just your output? (If the latter, then it doesn't matter whether you use else if; but also, it's probably using input that it may not be telling you about -- in other words, just because it works on your one or two sample inputs doesn't mean it actually works.)

8. Ok, so I changed all the other previous "if"except the first "if to "else if" and the int x, y to float x, y since the grader program said it wanted x and y to be float.

The grader program finally accepted it. Thanks!!!

9. I wouldn't have passed you. You haven't identified the quadrant. That is, if neither coordinate is zero??? Where does the program go if both are zero?