I have an assignment whcih is on distance between 2 points, its due tomorrow. i keep getting these errors can some one please help me out ASAP?
thanks bballer 69
Attached File(s)
-
Distance_between_two_points.txt (2.06K)
Number of downloads: 113




Posted 24 May 2007 - 06:09 AM
Distance_between_two_points.txt (2.06K)
Posted 24 May 2007 - 07:30 AM
#include <stdio.h>
#include <math.h>
#define BART 10
void distance(float coord[BART]);
int main ( void )
{
float coordx[100], coordy[100];
int i,j,k,l,m,n;
printf("Please input your set of co-ordinates, you may have up to 6 sets.\n\n");
printf("Please enter the first set of co-ordinates.\n");
for (i = 0; i < 3; i++) {
printf("x = :");
scanf("%f\n", &coordx[i]);
printf("Y:");
scanf("%f\n", &coordy[i]);
}
printf("Please enter the second set of co-ordinates, \n");
for (j = 0; j < 3; j++) {
printf("x = ");
scanf("%f\n", &coordx[j]);
printf("y = ");
scanf("%f\n", &coordy[j]);
}
printf("Please enter the thrid set of co-ordinates.\n");
for (k = 0; k < 3; k++) {
printf("x = :");
scanf("%f\n", &coordx[k]);
printf("Y:");
scanf("%f\n", &coordy[k]);
}
printf("Please enter the fourth set of co-ordinates, \n");
for (l = 0; l < 3; l++) {
printf("x = ");
scanf("%f\n", &coordx[l]);
printf("y = ");
scanf("%f\n", &coordy[l]);
}
printf("Please enter the fifth set of co-ordinates.\n");
for (m = 0; m < 3; m++) {
printf("x = :");
scanf("%f\n", &coordx[m]);
printf("Y:");
scanf("%f\n", &coordy[m]);
}
printf("Please enter the sixt set of co-ordinates, \n");
for (n = 0; n < 3; n++) {
printf("x = ");
scanf("%f\n", &coordx[n]);
printf("y = ");
scanf("%f\n", &coordy[n]);
}
return 0;
}
void distance( float coord[BART] ){
double dist1, dist2, dist3, coordx[100], coordy[100];
int i,j,k,l,m,n;
dist1 = sqrt((coordx[i]-coordx[j])*(coordx[i]-coordx[j]) + (coordy[i]-coordy[j])*(coordy[i]-coordy[j]));
printf(" The distance between the first set and second set of co-ordinates is: ");
printf("%f\n", dist1);
dist2 = sqrt((coordx[k]-coordx[l])*(coordx[k]-coordx[l]) + (coordy[k]-coordy[l])*(coordy[k]-coordy[l]));
printf(" The distance between the thrid set and fourth set of co-ordinates is: ");
printf("%f\n", dist2);
dist3 = sqrt((coordx[m]-coordx[n])*(coordx[m]-coordx[n]) + (coordy[m]-coordy[n])*(coordy[m]-coordy[n]));
printf(" The distance between the fifth set and sixth set of co-ordinates is: ");
printf("%f\n", dist3);
}
Posted 24 May 2007 - 11:31 AM
(coordx[i]-coordx[j])^2I see that PennyBoki fixed this already. The ^ character is a bit-wise exclusive-OR operator, not exponentiation.
Posted 24 May 2007 - 01:26 PM
