0
X,y coordinates in c using conditionals?
Keep getting errors for negative numbers saying it doesn't handle them right in the quadrants. I've used nested ifs if compounds I've used && I've used while and do and still I can't get it to rid of errors. Anyone know why? It says it doesn't take negatives correctly. Thank u it's my first c programming class but I'm stuck on this. I'm sure I'm overlooking something minor.my code is in the comments.
25 Answers
+ 1
#include <stdio.h>
Int main () {
Int x,y;
printf ("please enter coordinates for x and y\n");
scanf("%d %d", &x &y);
printf("%d,%d",x,y);
If (x>0 && y < 0)
{printf(â%d,%d lies in 1st quadrant \n â,x,y); }
Else If (x<0 && y> 0);
{printf(â %d,%d lies in 2nd %d\nâ,x,y);}
Else If (x > 0 && y> 0);
{printf(â%d,%d lies in 3rd quadrant\nâ,x,y);}
Else If (x< 0 && y < 0);
{printf(â%d,%d lies in 4th quadrant\n â,x,y);}
Else If (x==0 && y==0)
{printf(â%d,%d lies in the origin of 1st quadrant\n â,x,y);}
return 0; }
+ 1
That's great! I'm glad I actually did it right.thank u for ur help I appreciate it. hmm maybe it's setup for c99? I think there's c89 or is it 98? Would that change anything?
+ 1
Okay I will . Thank u so much it's fun learning all this and I get so into it I stay up late but yeah it is nice when someone can help and has experience. Thank you
+ 1
That's what I love about this site and the community it has
0
Of course thank you !
0
Yeah it's my text editor sorry about that. Those are errors that occurred in copy and paste. But when those are all fixed in the original it still says that it compiles but fails tests on the ide for quadrant 1-4 . With negative values I'm not sure why
0
I'm using codeboard.io and it's just not giving out successful tests if it inputs say -1000 it fails
0
It's just suppose to put any number in the right quadrant as far as my assignment directions go.
0
My teacher has it setup for c99 or c98 sorry im new to this but remember that detail he mentioned. Is that like different styles?
0
It shows that : test failed problem: failed to successfully take input for quadrants idk why it says that
0
I haven't modified it but im Still trying to see what I can change
0
Yeah c89 sounds more accurate to what I read. Would this still output any value and compile successful? In both of those standards
0
I've tried that and when I did I think I put x by itself and y by itself and scanf for each individual. But didn't work
0
That's what I thought too hmm so weird lol it's driving me nuts idk what it is lol
0
I wrote my teacher he modifies the ide board so hopefully he can give me a clue to what I need. Thank u tho I'm glad I understand it.