The compiler shows the error of cannot convert float to float at line 1.
I don't know what's going on about this error.
It is an easy program for calculating a distance between two point
I don't know what's going on about this error.
It is an easy program for calculating a distance between two point
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void Distance(float p1[],float p2[]);
int main(){
float p1[3] = { 0, 0 ,0 };
float p2[3] = { 3, 4 ,0 };
float dis;
dis = Distance(p1,p2);
printf("%f", dis);
system("pause");
return 0;
}
void Distance(float p1[],float p2[]){
float delta[3] ={0};
float del_square =0;
for (int i = 0; i < 3; i++){
delta[i] = p1[i] - p2[i];
}
for(int i = 0; i < 3; i++){
del_square += delta[i] * delta[i];
}
return sqrt(del_square);
}
Comment