How I can calculate the distance between two points based on their longitudes and latitudes?

Note that we have two points on a sphere, not on a plane, so we are finding the distance along a great circle.

We need to convert latitude and longitude values from decimal degrees to radians by dividing by 180/pi, or 57.29577951.

We need the radius of the earth, which is 3963.0 miles (or 6378.8 km).
If point A is (long1, lat1) in decimals and point B is (long2, lat2) in decimals, then

d <- 3963.0 * acos((sin(lat1/57.29577951)*sin(lat2/57.29577951)) +
cos(lat1/57.29577951)*cos(lat2/57.29577951)*cos(long2/57.29577951 - long1/57.29577951))

Example:
long1= 2.3522
lat1=48.8566
long2=19.9450
lat2=50.0647

d = 793.4522

See # Program for distance between two points on earth - GeeksforGeeks