Function Help !!

How would i turn this into a seperate function. Im not sure how to organize the return part of the function.

1
2
3
4
5
6
distancex=((point3-point1)*(point3-point1))
distancey=((point4-point2)*(point4-point2))

final =sqrt(distancey + distancex);

Didn't test it but it would be something like this.

int SqRtXY (int point1, point2, point3, point4)
{
distancex=((point3-point1)*(point3-point1))
distancey=((point4-point2)*(point4-point2))

final =sqrt(distancey + distancex);
return final;
}

int main()
{
int p1=1, p2=2, p3=3, p4=4;
cout << SqRtXY(p1, p2, p3, p4);
return 0;
}
Should i define distancex,distancey,final a double in the body or in the header.
usually a good programming practice (read it on forms) is to define the variables within the function and make them local, unless you want them to be global and accessed by anyone you may define them within the functions...
Topic archived. No new replies allowed.