I want to calculate the distance between two points but I need to do it by using a main function. I am having some difficulties in trying to make sure that my program returns the correct value. I have attached my code to this so I would appreciate it if anyone can help in correcting the portion that I may have made a mistake. (Note: I am fairly new to C so I may need some additional help in understanding some things.)
#include <stdio.h>
double distance(double x1, double y1, double x2, double y2)
{
    double square_difference_x = (x2 - x1) * (x2 - x1);
    double square_difference_y = (y2 - y1) * (y2 - y1);
    double sum = square_difference_x + square_difference_y;
    double z = 0.00001;
    for (double i = 0; i < sum; i = i + z)
    {
        if (i * i == sum)
        {
            return i;
        }
    }
}
int main(void)
{
    double a = 1.0, b = 2.0, c = 4.0, d = 6.0;
    double dis;
    dis = distance(a, b, c, d);
    printf("The distance of the points (%lf, %lf) and (%lf, %lf) is %lf\n",  a,b,c,d,dis);
    return 0;
}
I feel like my problem is happening with the return option in the main function although I am not so sure how to fix this problem if there is one. 
`
 
     
     
    