I was trying to make a simple C program which, given X and Y coordinates, tells the quadrant. I'm getting an error:
cordinate.c: In function ‘main’:
cordinate.c:28:1: error: expected ‘;’ before ‘{’ token
As far as I know syntax-wise i's correct.
Code:
#include <stdio.h>
void main() {
int x, y;
printf("enter the cordinate x and y\n");
scanf("%d%d",&x,&y);
if ((x > 0) && (y > 0)) {
printf("The point lies in 1st quadrant \n");
} else if ((x < 0) && (y > 0)) {
printf("The point lies in 2nd quadrant \n");
} else if ((x < 0) && (y < 0)) {
printf("The point lies in 3rd quadrant \n");
} else ( (x>0) && (y<0) )
{
printf("The point lies in 4th quadrant \n");
}
}
And when I do whatever is said I get the output as
input
22
33
output
The point lies in 1st quadrant
The point lies in 4th quadrant
Can anyone explain this?