Hello everyone.

I'm trying to write a program where a user will enter a set of x,y coordinates and the program will sort them based on their distance from the origin using sqrt (x*x + y*y). The x and y coordinates each go into their own array, but are supposed to be sorted in one function.

This is what i have so far.

Code:

#include <stdio.h>
#include <math.h>
#define MAX_LIST_SIZE 10
float calc_z (int x, int y);
void sort_xy (int x[], int y[]);
int i,j,hold, choice, coordNumber;
int x[MAX_LIST_SIZE], y[MAX_LIST_SIZE];
void main () {
while (1) {
printf ("Enter (1) to run (2) to quit: ");
scanf ("%d", &choice);
if (choice == 2) return;
else {
printf("How many coordinates do you want to enter in: ");
scanf ("%d", &coordNumber);
for (i = 0; i < coordNumber; i++) {
printf ("enter x,y: ");
scanf ("%d,%d", &x[i], &y[i]);
}
void sort_xy (int x[], int y[]);
for (i = 0; i < coordNumber; i++) {
printf("%d %d\n", x[i], y[i]);}
}
}
}
void sort_xy (int x[], int y[]){
for (j=1; j<coordNumber; j++){
for (i=0; i < coordNumber-1; i++){
/* VV Problem here probably VV*/
if (float sqrt(x[i]*x[i]+y[i]*y[i]) > float sqrt(x[i+1]*x[i+1]+y[i+1]*y[i+1])) {
hold= x[i+1];
x[i + 1]=x[i];
x[i] = hold;
}}}}

When I try to build this I get the following errors:

error C2061: syntax error : identifier 'x'

: error C2059: syntax error : '>'

error C2143: syntax error : missing ';' before '{'

I have tried using another function to figure out the distance, but I couldn't figure out how to incorporate it into the sorting one.

If someone could point this noob in the right direction it would be greatly appreciated.