^ does not do exponentiation in C, it does an XOR.
Code:
#include <stdio.h>
#include <math.h>
double distance(double x1, double y1, double x2, double y2)
{
return sqrt(pow(x2-x1,2) + pow(y2-y1,2));
}
int main(void)
{
double dist = distance(0,0,3,4);
printf("dist = %g\n", dist);
return 0;
}
/* my output
dist = 5
*/