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.

27th May 2019, 8:59 AM
bleu trees0101
bleu trees0101 - avatar
25 Respuestas
+ 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; }
27th May 2019, 11:43 AM
bleu trees0101
bleu trees0101 - avatar
+ 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?
27th May 2019, 12:49 PM
bleu trees0101
bleu trees0101 - avatar
+ 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
27th May 2019, 1:15 PM
bleu trees0101
bleu trees0101 - avatar
+ 1
That's what I love about this site and the community it has
27th May 2019, 1:15 PM
bleu trees0101
bleu trees0101 - avatar
0
Of course thank you !
27th May 2019, 11:22 AM
bleu trees0101
bleu trees0101 - avatar
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
27th May 2019, 12:07 PM
bleu trees0101
bleu trees0101 - avatar
0
I'm using codeboard.io and it's just not giving out successful tests if it inputs say -1000 it fails
27th May 2019, 12:08 PM
bleu trees0101
bleu trees0101 - avatar
0
It's just suppose to put any number in the right quadrant as far as my assignment directions go.
27th May 2019, 12:52 PM
bleu trees0101
bleu trees0101 - avatar
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?
27th May 2019, 12:53 PM
bleu trees0101
bleu trees0101 - avatar
0
It shows that : test failed problem: failed to successfully take input for quadrants idk why it says that
27th May 2019, 12:55 PM
bleu trees0101
bleu trees0101 - avatar
0
I haven't modified it but im Still trying to see what I can change
27th May 2019, 12:56 PM
bleu trees0101
bleu trees0101 - avatar
0
Yeah c89 sounds more accurate to what I read. Would this still output any value and compile successful? In both of those standards
27th May 2019, 12:58 PM
bleu trees0101
bleu trees0101 - avatar
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
27th May 2019, 1:00 PM
bleu trees0101
bleu trees0101 - avatar
0
That's what I thought too hmm so weird lol it's driving me nuts idk what it is lol
27th May 2019, 1:01 PM
bleu trees0101
bleu trees0101 - avatar
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.
27th May 2019, 1:02 PM
bleu trees0101
bleu trees0101 - avatar