Distance between two coordinates

This is the code I have translated! the distance that is shown differs:
d = 15.96 d = 7.54
I got those distances with the same geographic coordinates

// Finding the distance between two coordinates
float lat2 = 31.318532, lon2= 75.630783;
double r = 6378100;

float dLat = (lat2-flat) * 3.14 / 180; //degree to radian conversion
float dLon = (lon2-flon) * 3.14 / 180;

float lat1 = (flat) * 3.14 / 180;
float lat3 = (lat2) * 3.14 / 180;

float a = sin(dLat/2) * sin(dLat/2) + sin(dLon/2) * sin(dLon/2) * cos(lat1) * cos(lat3);
float c = 2 * atan2(sqrt(a), sqrt(1-a));
float d = r * c;
Serial.print(" a: ");
Serial.print(a);
Serial.print(" Distance: ");
Serial.print(d);