# Calculate coordinates of a struct with more than 2 x and y coords

I have a program where a user is asked to how many xy coordinates they want to enter. Then I would calculate the distance of the coordinates.

For example if the enter they want to put 3 coordinates I would calculate sqrt(pow(x0-x1,2) pow(x0-x2,2) pow(x1-x2) + pow(y0-y1,2) pow(y0-y2,2) pow(y1-y2)).

Calculating the distance is where I get stuck. Tried a nested loop.

```
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
int numOfCoords;
struct CoordApp{
double x;
double y;
char xLabel[20];
char yLabel[20];
};
int main()
{
int i, j, k;
char num[5];
double minX, minY, distance, l, m;
do
{
printf("How many coordinates do you want to enter? \nPlease enter more than 2 coordinates:");
scanf("%d", &numOfCoords);
}while(numOfCoords <= 2); //Request more than 2 coordinates
struct CoordApp coords[numOfCoords]; // Assign a new struct
for(i=0; i<numOfCoords; i++) // Get X and Y coordinates
{
do
{
printf("Please enter x coordinate %d:", i);
scanf("%lf", &coords[i].x);
printf("Please enter y coordinate %d:", i);
scanf("%lf", &coords[i].y);
}while(coords[i].x < 0 || coords[i].y < 0); // Check for positive coords
strcpy(coords[i].xLabel, "XCoord");
strcat(coords[i].xLabel, itoa(i,num,5));
strcpy(coords[i].yLabel, "YCoord");
strcat(coords[i].yLabel, itoa(i,num,5));
}
for(j=0; j<numOfCoords; j++)
{
for(k=0; k<sizeof(coords)/sizeof(coords[j]); k++)
{
distance=sqrt(pow(coords[k].x-coords[j].x,2 ) + pow(coords[k].y - coords[j].y, 2)) ;
}
printf("[%lf][%lf]", coords[j].x,coords[j].y);
}
return 0;
}
```

Thank you for helping me with this