help with c# program
Hey guys I'm working on a C# program that gets the X and Y input from a user, and then determines which quadrant the x,y is in. It needs to determine the position of the point as a function of the two paramaters, x and y. Heres what I have so far. Can you guys give me some suggestions how to fix the errors? thanks
i realize that I need to call the function from below, but I cant think of any simple ways to do it.
and btw #include <stdio.h isnt showing up in the code down below for some reason, but its there, just trust me on it.
when I compile it I get the error l
ab4.c:25: error: expected identifier or '(' before '{' token
i realize that I need to call the function from below, but I cant think of any simple ways to do it.
and btw #include <stdio.h isnt showing up in the code down below for some reason, but its there, just trust me on it.
#include <stdio.h>
int main (void) {
double x,y;
printf("Enter the X value");
scanf("%lf", &x);
printf("Enter the y value");
scanf("%lf", &y);
return (0);
}
{
double x,y;
if (x==0 && y==0)
printf("The point is on the origin");
else
if (x==0)
printf("The point is on the X axis");
else
if (y==0)
printf("The point is on the Y axis");
else
if (x>0 && y>0)
printf("The point is in quadrant 1");
else
if (x<0 && y>0)
printf("The point is in quadrant 2");
else
if (x<0 && y<0)
printf("The point is in quadrant 3");
else
if (x>0 && y<0)
printf("The point is in quadrant 4");
return (0);
}
when I compile it I get the error l
ab4.c:25: error: expected identifier or '(' before '{' token
0
Comments
int aFunctionName (whatever your arguments are {it might be good to pass it x and y}) { double x,y; if (x==0 && y==0) printf("The point is on the origin"); else if (x==0) printf("The point is on the X axis"); else if (y==0) printf("The point is on the Y axis"); else if (x>0 && y>0) printf("The point is in quadrant 1"); else if (x<0 && y>0) printf("The point is in quadrant 2"); else if (x<0 && y<0) printf("The point is in quadrant 3"); else if (x>0 && y<0) printf("The point is in quadrant 4"); return (0); }#include <stdio.h> double coordinate (double, double); int main (void) { double x,y; printf("Enter the X value\n"); scanf("%lf", &x); printf("Enter the y value\n"); scanf("%lf", &y); printf("%1.2f", coordinate (x, y)); return (0); } double coordinate (double x, double y) { if (x == 0 && y == 0) printf("The point is on the origin.\n"); else if (x == 0 && y > 0) printf("The point is on the positive y axis.\n"); else if (x == 0 && y < 0) printf("The point is on the negative y axis.\n"); else if (y == 0 && x > 0) printf("The point is on the positive x axis.\n"); else if (y == 0 && x < 0) printf("The point is on the negative x axis.\n"); else if (x > 0 && y > 0) printf("The point is in quadrant 1.\n"); else if (x < 0 && y > 0) printf("The point is in quadrant 2.\n"); else if (x < 0 && y < 0) printf("The point is in quadrant 3.\n"); else if (x > 0 && y < 0) printf("The point is in quadrant 4.\n"); return (0); }