Well, after doing Java programming for about a year, as a hobby. I decided to try and get a grasp on C. Right now, I am trying to make a program with a custom function that finds the distance between two points on a 3D graph and got it written correctly, as far as I know, but GCC gives me an error.
the error is:
However, I look at the code and there is nothing that changes the datatype of that variable and it is only declared once. What am I doing wrong?
the source code looks like this:
the error is:
‘y1’ redeclared as different kind of symbol
However, I look at the code and there is nothing that changes the datatype of that variable and it is only declared once. What am I doing wrong?
the source code looks like this:
Code:
#include <stdio.h>
#include <math.h>
float x1, x2, y1;
float y2, z1, z2;
float dist3d (float ux, float uy, float uz, float vx, float vy, float vz);
int main()
{
printf("Enter the first point in form of (x, y, z) without commas or parenthesis: ");
scanf ("%f %f %f", &x1, &y1, &z1);
printf("Enter the second point in form of (x, y, z) without commas or parenthesis: ");
scanf ("%f %f %f", &x2, &y2, &z2);
printf("The distance between (%f, %f, %f) and (%f, %f, %f) is: %f\n", x1, y1, z1, x2, y2, z2, dist3d(x1, y1, z1, x2, y2, z2));
return 0;
} /* end of program */
float dist3d(float ux, float uy, float uz, float vx, float vy, float vz)
{
return sqrt(pow((vx - ux), 2) + pow((vy - uy), 2) + pow((vz - uz), 2));
}